protected function _beforeEntityInsert(AnCommandContext $context)
193648
protected function _onEntityValidate(AnCommandContext $context)
    {
        if ($this->nodeA->id === $this->nodeB->id) {
            return false;
        }

        return true;
    }
1349055
protected function _beforeInsert(KDatabaseContext $context)
    {
        $method = 'get'.ucfirst($this->_column);
        if($context->data->$method() instanceof KObjectConfigInterface) {
            $context->data->setProperty($this->_column, $context->data->$method()->toString());
        }
    }
44523
protected function _beforeInsert(KDatabaseContextInterface $context)
    {
        if($this->hasProperty('ordering'))
        {
            if($this->ordering <= 0) {
                $this->ordering = $this->getMaxOrdering() + 1;
            } else {
                $this->reorder($this->ordering);
            }
        }
    }
1242773
public function beforeInsert($model, &$data)
    {
        if ($this->weak) {
            return;
        }

        if ($model->hasField($this->master_field)
            && $model[$this->master_field]
        ) {
            // The value for the master_field is set,
            // we are going to use existing record.
            return;
        }

        // Figure out where are we going to save data
        $persistence = $this->persistence ?:
            $this->owner->persistence;

        $this->id = $persistence->insert(
            $model,
            $this->save_buffer,
            $this->foreign_table
        );

        $data[$this->master_field] = $this->id;

        //$this->owner->set($this->master_field, $this->id);
    }
18739
protected function _actionAddapp(AnCommandContext $context)
    {
        $data = $context->data;
        $this->getItem()->components->insert($data->app);
        $this->commit();
    }
1088446
protected function _actionAdd(AnCommandContext $context)
    {
        $data = $context->data;
        $email = $data->email;
        //an email
        $person = $this->getService('repos:people.person')
                      ->getQuery()
                      ->email($email)
                      ->where('IF(!@col(enabled),@col(activationCode) <> \'\',1)')
                      ->disableChain()
                      ->fetch();

        if ($person) {
            $person->requiresReactivation()->save();
            $this->getResponse()->status = AnHttpResponse::CREATED;
            $this->person = $person;
        } else {
            throw new LibBaseControllerExceptionNotFound('Email Not Found');
        }
    }
562813
public function instantiateDataFromSession(AnCommandContext $context)
    {
        $data = $context->data;
        $package = $this->getItem();

        //create a dummy transaction
        $viewer = get_viewer();
        $this->order = $this->getService('repos:subscriptions.order')->getEntity()->reset();
        $this->order->setPackage($package, $viewer->hasSubscription() ? $viewer->subscription->package : null);

        $this->_instantiateCoupon($data);
        $this->_instantiateUser($data);
        $this->_instantiateCreditCard($data);
    }
26567
public function beforeCompile(): void
	{
		// Skip if it's not CLI mode
		if (!$this->cliMode) {
			return;
		}

		$builder = $this->getContainerBuilder();

		// Lookup for Symfony Console Application
		$application = $builder->getDefinitionByType(Application::class);

		// Register helpers
		$entityManagerHelper = $this->prefix('@entityManagerHelper');
		$application->addSetup(new Statement('$service->getHelperSet()->set(?,?)', [$entityManagerHelper, 'em']));
	}
26290
protected function _beforeEdit(KControllerContextInterface $context)
    {
        if ($this->getMixer()->getIdentifier()->name === $this->_category_entity)
        {
            $collection = $this->getModel()->fetch();

            foreach ($collection as $entity)
            {
                $entity->old_enabled = $entity->enabled;
                $entity->old_access  = $entity->access;
            }
        }
    }
1232797
protected function _actionEditsubscription(AnCommandContext $context)
    {
        if ($subscription = $this->_subscriber->changeSubscriptionTo($this->getItem())) {
            $subscription->endDate = $context->data->endDate;
        }
    }
156626
protected function _afterEntityDelete(AnCommandContext $context)
    {
        if (!empty($this->__sets)) {
            foreach ($this->__sets as $set) {
                if ($set->photos->getTotal() == 0) {
                    $set->delete();
                }
            }
        }
    }
753760
protected function _actionPrepclienv(AnCommandContext $context)
    {
        if (! empty($_SERVER['argv']) && count($_SERVER['argv']) > 1) {
            $args = array_slice($_SERVER['argv'], 1);

            if (is_readable(realpath($args[0]))) {
                $file = array_shift($args);
            }

            $args = explode('&-data&', implode($args, '&'));
            $args = array_filter($args, 'trim');

            foreach ($args as $i => $arg) {
                $arg = trim($arg);

                if ($i == 0) {
                    if (strpos($arg, '/') !== false) {
                        $arg = substr_replace($arg, '?', strpos($arg, '&'), 1);
                        $url = AnService::get('anahita:http.url', array('url' => $arg));
                        AnRequest::url()->path = AnRequest::base().$url->path;
                        $_GET = $url->query;
                    } else {
                        AnRequest::url()->path = AnRequest::base();
                        parse_str($arg, $_GET);
                    }
                } else {
                    parse_str($arg, $_POST);
                }
            }
        }

        $_GET['format'] = 'json';
        AnRequest::url()->format = 'json';
        AnRequest::url()->setQuery($_GET);

        AnService::get('com:plugins.helper')->import('cli');
        dispatch_plugin('cli.onCli');

        //if there's a file then just load the file and exit
        if (! empty($file)) {
            AnService::get('anahita:loader')->loadFile($file);
            exit(0);
        }
    }
323463
protected function _actionAdd(AnCommandContext $context)
    {
        $context->response->status = AnHttpResponse::CREATED;
        $entity = $this->getRepository()->getEntity()->setData($context['data']);
        $this->setItem($entity);

        return $this->getItem();
    }
338952
protected function _afterEntityDelete(AnCommandContext $context)
    {
        $this->ownable->getRepository()->getBehavior('sharable')->resetStats(array($this->ownable));
    }
341318
protected function _afterEntityDelete(AnCommandContext $context)
    {
        $this->votee->getRepository()
                    ->getBehavior('votable')
                    ->resetStats(array($this->votee));
    }
418694
protected function _afterEntityDelete(AnCommandContext $context)
    {
        $this->getSpace()->setEntityState($context->entity, AnDomain::STATE_DESTROYED);
    }
91910
protected function _afterRepositoryFetch(AnCommandContext $context)
    {
        $query = $context->query;

        if ($context->mode != AnDomain::FETCH_VALUE && $query->aggregate_keys) {
            $this->_preloadData($context->data);
        }
    }