Object referenced by this object
@param null|bool $new Новое значение признака
@param bool $return_entity Признак, возвращать объект вместо uri
@return bool|Entity
325620
function is_link($new = null, $return_entity = false)
    {
        if (isset($new) && ($this->_attributes['is_link'] != $new)){
            $this->change('is_link', (bool)$new);
        }
        if ($return_entity){
            if (!isset($this->_link)){
                if (empty($this->_attributes['is_link'])){
                    $this->_link = false;
                }else
                if (($this->_link = $this->proto(null, true))){
                    if ($p = $this->_link->is_link(null, true)) $this->_link = $p;
                }
            }
            return $this->_link;
        }
        return $this->_attributes['is_link'];
    }
623869
public function newAction()
    {
        $entity = new Service();
        $form   = $this->createCreateForm($entity);

        return array(
            'entity' => $entity,
            'form'   => $form->createView(),
        );
    }
747140
public function create(bool $returnID = false, bool $pull_force = false)
    {
        $url = self::$base_url.'/'.__FUNCTION__.'?'.http_build_query(['name' => $this->container_name]);

        $this->setCreateJson(null);

        $this->docker_image->pull($this->image, 'latest', $pull_force);

        $json = self::$curl->post($url, $this->getCreateJson(), self::$header);

        $id = json_decode($json)->Id ?? null;

        if (null === $id) {
            throw new Exception(json_decode($json)->message ?? $json, self::$curl->getCode());
        }

        $this->container_id = $id;

        $this->container_name = null;
        $this->cleanupConfig();

        if ($returnID) {
            return $id;
        }

        return $this;
    }
1373746
public function createInstance()
    {
        if (is_null($this->entityName)) {
            $class = new \ReflectionClass($this->originalEntityName);
        } else {
            $class = new \ReflectionClass($this->entityName);
        }

        return $class->newInstanceArgs();
    }
75471
public function newAction()
    {
        $entity = new Tag();
        $form   = $this->createCreateForm($entity);

        return array(
            'entity' => $entity,
            'form'   => $form->createView(),
        );
    }
672064
public function newInstance()
    {
        $class = $this->entityMap->getClass();

        if ($this->entityMap->useDependencyInjection()) {
            return $this->newInstanceUsingDependencyInjection($class);
        }

        return $this->newInstanceUsingInstantiator($class);
    }
799103
function is_default_value($new = null, $return_entity = false)
    {
        if (isset($new) && ($this->_attributes['is_default_value'] != $new)){
            $this->change('is_default_value', (bool)$new);
            if ($this->_attributes['is_default_value']){
                $this->change('value', null);
            }
        }
        if ($return_entity){
            if (!isset($this->_def_value)){
                if (empty($this->_attributes['is_default_value'])){
                    $this->_def_value = false;
                }else
                if (($this->_def_value = $this->proto(null, true))){
                    if ($p = $this->_def_value->is_default_value(null, true)) $this->_def_value = $p;
                }
            }
            return $this->_def_value;
        }
        return $this->_attributes['is_default_value'];
    }
1256869
public function new()
    {
        if (isset($this->constructor)) {
            $constructor = $this->constructor;
            $arguments = func_get_args();
            $callback = array_pop($arguments);

            $input_count = isset($constructor['inputs']) ? count($constructor['inputs']) : 0;
            if (count($arguments) < $input_count) {
                throw new InvalidArgumentException('Please make sure you have put all constructor params and callback.');
            }
            if (is_callable($callback) !== true) {
                throw new \InvalidArgumentException('The last param must be callback function.');
            }
            if (!isset($this->bytecode)) {
                throw new \InvalidArgumentException('Please call bytecode($bytecode) before new().');
            }
            $params = array_splice($arguments, 0, $input_count);
            $data = $this->ethabi->encodeParameters($constructor, $params);
            $transaction = [];

            if (count($arguments) > 0) {
                $transaction = $arguments[0];
            }
            $transaction['data'] = '0x' . $this->bytecode . Utils::stripZero($data);

            $this->eth->sendTransaction($transaction, function ($err, $transaction) use ($callback){
                if ($err !== null) {
                    return call_user_func($callback, $err, null);
                }
                return call_user_func($callback, null, $transaction);
            });
        }
    }
144957
public function getQuery($new = false)
    {
        if (!$this->query || $new) {
            $this->query = $this->db->getQuery(true);
        }

        return $this->query;
    }
1344975
public static function getWebhookPayload($returnObject = false) {
        $data = file_get_contents("php://input");
        if ($data) {
            return self::jsonDecode($data, !$returnObject);
        } else {
            return null;
        }
    }
112326
public function getReader($query = null, $new = true)
    {
        if ($query) {
            $this->setQuery($query);
        }

        if (!$this->reader || $new) {
            $class = sprintf('Windwalker\\Database\\Driver\\%s\\%sReader', ucfirst($this->name), ucfirst($this->name));

            $this->reader = new $class($this);
        }

        return $this->reader;
    }
419140
public function newAction()
    {
        $entity = new Collection();
        $form = $this->createCreateForm($entity);

        return array(
            'entity' => $entity,
            'form' => $form->createView(),
        );
    }
547845
public function newInstance(
        string $createdByUserId,
        string $createdReason = Tracking::UNKNOWN_REASON
    ) {
        /** @var static $new */
        $new = parent::newInstance(
            $createdByUserId,
            $createdReason
        );

        // if no id, then it has not been save and can be returned
        if (empty($new->pageId)) {
            return $new;
        }

        $new->pageId = null;
        $new->name = null;
        $new->parent = null;

        return $new;
    }
538127
public function fetch($return = self::RETURN_COLLECTION) {
        /** We replace Post.xx by post.xx */
        foreach ($this->_entities as $entity) {
            $class = $this->_getTableEntity($entity);

            if ($entity != $class->name()) {
                $this->_query = preg_replace('#(.*)' . $entity . '\.(.*)#isU', '$1' . $class->name() . '.$2', $this->_query);
            }
        }

        /** Query execution */
        $sql = new Sql();
        $sql->vars($this->_vars);
        $sql->query('orm-' . $this->_token, $this->_query);

        if ($this->_type == self::QUERY_COUNT) {
            return $sql->fetch('orm-' . $this->_token, Sql::PARAM_FETCHCOLUMN);
        }
        else {
            $sql->fetch('orm-' . $this->_token, Sql::PARAM_FETCH);
        }

        $collection = $sql->data($this->_getEntityName($this->_entity->name()));

        /** We can do SELECT OR SELECT DISTINCT OR SELECT RAW */
        if (in_array($this->_type, [self::QUERY_DISTINCT, self::QUERY_RAW])) {
            $nLines = $collection->count();
            $in = '';

            /** @var $value \Gcs\Framework\Core\Orm\Entity\Entity */
            foreach ($collection as $key => $value) {
                $in .= $value->fields()[$value->primary()]->value;

                if ($key < $nLines - 1) {
                    $in .= ', ';
                }
            }

            $builder = new Builder($this->_entity);
            $collection = $builder->find()->where($this->_entity->name() . '.' . $this->_entity->primary() . ' IN (' . $in . ')')->fetch();
        }

        /** If we have fields with a relation ONE TO MANY OR MANY TO MANY */
        foreach ($this->_entity->fields() as $field) {
            if ($field->foreign != null && in_array($field->foreign->type(), [ForeignKey::ONE_TO_MANY, ForeignKey::MANY_TO_MANY])) {
                /** we loop through the results to add each time */
                switch ($field->foreign->type()) {
                    case ForeignKey::ONE_TO_MANY :
                        $collection = $this->_dataOneToMany($field, $collection);
                        break;

                    case ForeignKey::MANY_TO_MANY :
                        $collection = $this->_dataManyToMany($field, $collection);
                        break;
                }
            }
        }

        if ($return == self::RETURN_ENTITY && $collection->count() <= 1) {
            return $collection->first();
        }
        else {
            return $collection;
        }
    }
455492
public function newQuery($returnType=Builder::RETURN_TYPE_ELOQUENT)
    {
        $builder = $this->newQueryWithoutScopes($returnType);

        // laravel 5.1
        if (method_exists($this, 'applyGlobalScopes')) {
            return $this->applyGlobalScopes($builder);
        }

        // laravel 5.2
        foreach ($this->getGlobalScopes() as $identifier => $scope) {
            $builder->withGlobalScope($identifier, $scope);
        }

        return $builder;
    }
966543
public function getReturnUri()
    {
        if ( null === $this->returnUri )
        {
            $request    = $this->getRequest();
            $session    = $this->getSessionContainer();
            $returnUri  = $request->getQuery( 'requestUri' );

            if ( empty( $returnUri ) )
            {
                $returnUri = $request->getPost( 'requestUri' );
            }

            if ( empty( $returnUri ) )
            {
                if ( isset( $session['returnUri'] ) )
                {
                    $returnUri = $session['returnUri'];
                }
                else
                {
                    $returnUri = self::DEFAULT_RETURN_URI;
                }
            }
            else
            {
                $session['returnUri'] = $returnUri;
            }

            if ( empty( $returnUri ) )
            {
                return '/';
            }

            $this->returnUri = $returnUri;
        }

        return $this->returnUri;
    }
386603
public function createAction()
    {
        // Load form
        $entityClass = $this->getModuleNamespace() . '\Entity\\' . $this->getEntityName();
        $entity      = new $entityClass();
        $form        = $this->getForm('Create' . $this->getEntityName());
        $form->bind($entity);

        // Implement Post/Redirect/Get pattern
        $prg = $this->prg();
        if ($prg instanceof Response) {
            return $prg;
        } else if (false !== $prg) {

            // Set form data
            $form->setData($prg);

            // Create account
            $result = $this->getService()->create();
            if ($result) {
                return $this->redirect()->toRoute($this->indexRoute);
            }
        }

        // Set up view model
        $viewModel = new ViewModel(array(
            'entityName' => $this->getEntityName(),
            'form'       => $form,
        ));
        $viewModel->setTemplate('infinity-base/crud/create');

        return $viewModel;
    }