28 parent::executeBefore();
30 $type = $this->request->getHttpRequest()->getRoute()?->getOption(
'entity_type');
31 $subtype = $this->request->getHttpRequest()->getRoute()?->getOption(
'entity_subtype');
37 if (empty($entity_class)) {
41 $guid = (int) $this->request->getParam(
'guid');
44 if (!$entity instanceof $entity_class) {
48 if (!$entity->canEdit()) {
52 $this->is_new_entity =
false;
55 $entity =
new $entity_class();
59 if (!
$container || !
$container->canWriteToContainer(0, $entity->getType(), $entity->getSubtype())) {
76 protected function execute(array $skip_field_names = []):
void {
79 foreach ($this->entity->getFields() as
$field) {
81 if (in_array(
$name, $skip_field_names)) {
88 if ($field_type ===
'tags') {
94 if ($field_type ===
'file') {
96 if ($uploaded_file && !$uploaded_file->isValid()) {
101 if ($field_type ===
'url' && !filter_var(
$value, FILTER_VALIDATE_URL)) {
109 if ($field_type ===
'file') {
124 parent::executeAfter();
126 if (!$this->entity->save()) {
130 if ($this->request->getParam(
'header_remove')) {
131 $this->entity->deleteIcon(
'header');
133 $this->entity->saveIconFromUploadedFile(
'header',
'header');
146 'action_type' =>
'create',
147 'object_guid' => $this->entity->guid,
148 'target_guid' => $this->entity->container_guid,
153 "entity:edit:{$this->entity->getType()}:{$this->entity->getSubtype()}:success",
154 "entity:edit:{$this->entity->getType()}:success",
elgg_get_entity_class(string $type, string $subtype)
Return the class name registered as a constructor for an entity of a given type and subtype...
if(!$user||!$user->canDelete()) $name
elgg_get_uploaded_file(string $input_name, bool $check_for_validity=true)
Returns a single valid uploaded file object.
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is void
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
elgg_create_river_item(array $options=[])
Elgg river.
if($item instanceof\ElggEntity) elseif($item instanceof\ElggRiverItem) elseif($item instanceof\ElggRelationship) elseif(is_callable([$item, 'getType']))
success(?string $forward_url=null)
{}
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
execute(array $skip_field_names=[])
{}
elgg_ok_response($content= '', string|array $message= '',?string $forward_url=null, int $status_code=ELGG_HTTP_OK)
Prepares a successful response to be returned by a page or an action handler.
elgg_language_key_exists(string $key, string $language= 'en')
Check if a given language key exists.
get_entity(int $guid)
Loads and returns an entity object from a guid.
Thrown when entity can not be edited or container permissions do not allow it to be written...
Generic entity edit action controller.
Thrown when the server encountered a generic error.
if(!$entity->delete(true, true)) $forward_url
elgg_get_friendly_upload_error(int $error_code)
Returns a human-readable message for PHP's upload error codes.
Generic action controller.
if(!$entity->save()) $success_keys
Action validation exception.
elgg_get_logged_in_user_guid()
Return the current logged in user by guid.
isNewEntity()
Is the entity being saved a new entity or being updated.
$guid
Reset an ElggUpgrade.