Create CreateSourceBackbone instance

@param  ContextInterface                             $context
@return \CrudGenerator\Backbone\CreateSourceBackbone
760365
public static function getInstance(ContextInterface $context)
    {
        return new CreateSourceBackbone(
            MetadataSourceQuestionFactory::getInstance($context),
            MetaDataConfigDAOFactory::getInstance($context),
            $context
        );
    }
293477
public static function create($product, $resource, ClientContext $context)
    {
        $rm = new ResourceMetadata($product, $resource);
        $resourceServiceClass = $rm->resourceServiceClass;
        return new $resourceServiceClass($rm, $context);
    }
572506
private function createExclusionStrategies(FOSContext $context)
    {
        $exclusionStrategies = [];

        $groups = $context->getGroups();
        $version = $context->getVersion();

        if (!empty($groups)) {
            $exclusionStrategies[] = new GroupsExclusionStrategy($groups);
        }

        if (!empty($version)) {
            $exclusionStrategies[] = new VersionExclusionStrategy($version);
        }

        if (method_exists($context, 'isMaxDepthEnabled')) {
            if ($context->isMaxDepthEnabled()) {
                $exclusionStrategies[] = new MaxDepthExclusionStrategy();
            }
        } else {
            $maxDepth = $context->getMaxDepth();

            if (!empty($maxDepth)) {
                $exclusionStrategies[] = new MaxDepthExclusionStrategy($maxDepth);
            }
        }

        $customExclusionStrategies = $context->getAttribute($attribute = 'ivory_exclusion_strategies') ?: [];

        if (!is_array($customExclusionStrategies) && !$customExclusionStrategies instanceof \Traversable) {
            throw new \RuntimeException(sprintf(
                'The "%s" context attribute must be an array or implement "%s".',
                $attribute,
                \Traversable::class
            ));
        }

        foreach ($customExclusionStrategies as $customExclusionStrategy) {
            if (!$customExclusionStrategy instanceof ExclusionStrategyInterface) {
                throw new \RuntimeException(sprintf(
                    'The "%s" context attribute must be an array of "%s", got "%s".',
                    $attribute,
                    ExclusionStrategyInterface::class,
                    is_object($customExclusionStrategy)
                        ? get_class($customExclusionStrategy)
                        : gettype($customExclusionStrategy)
                ));
            }

            $exclusionStrategies[] = $customExclusionStrategy;
        }

        return $exclusionStrategies;
    }
1307923
public function getContext(ViewContextInterface $context = null)
    {
        $context = new ViewContextTemplate(parent::getContext());
        $context->setLayout($this->getLayout());

        return $context;
    }
973900
private function createParamsFromContext(ClientMethodContext $context): ParameterGenerator
    {
        if (!$context->isMultiArgument()) {
            $param = current($context->getMethod()->getParameters());

            return ParameterGenerator::fromArray($param->toArray());
        }

        return ParameterGenerator::fromArray(
            [
                'name' => 'multiArgumentRequest',
                'type' => MultiArgumentRequest::class,
            ]
        );
    }
660191
protected function createProcessorIterator(ContextInterface $context)
    {
        $action = $context->getAction();
        $actionProcessors = [];
        $processors = $this->configProvider->getProcessors();
        if (!empty($processors[$action])) {
            $actionProcessors = $processors[$action];
        }

        return $this->processorIteratorFactory->createProcessorIterator(
            $actionProcessors,
            $context,
            $this->processorApplicableChecker,
            $this->processorFactory
        );
    }
226647
protected function _actionCreate(ModelContext $context)
    {
        //Get the data
        $data = ModelContext::unbox($context->properties);

        //Create the entity identifier
        $identifier = $this->getIdentifier()->toArray();
        $identifier['path'] = array('model', 'entity');

        if($data && !is_numeric(key($data))) {
            $identifier['name'] = StringInflector::singularize($identifier['name']);
        } else {
            $identifier['name'] = StringInflector::pluralize($identifier['name']);
        }

        $options = array(
            'data'         => $data,
            'identity_key' => $context->getIdentityKey()
        );

        return $this->getObject($identifier, $options);
    }
823128
private function configureContext(Context $context)
    {
        foreach ($this->attributes as $key => $value) {
            $context->setAttribute($key, $value);
        }
        if (!empty($this->groups)) {
            $context->setGroups($this->groups);
        }

        if (($context instanceof SerializationContext) && $this->serializeNulls !== null) {
            $context->setSerializeNull($this->serializeNulls);
        }

        if ($this->enableMaxDepthChecks === true) {
            $context->enableMaxDepthChecks();
        }

        if ($this->version !== null) {
            $context->setVersion($this->version);
        }

        return $context;
    }
134988
public function getContext(ModelContextInterface $context = null)
    {
        $context = new ModelContext($context);
        $context->setState($this->getState());
        $context->setIdentityKey($this->_identity_key);

        return $context;
    }
1124069
public function build($definition, $context = null, $name = null)
    {
        if ($definition instanceof ProviderInterface) {
            return $this->getProviderValue($definition, $context);
        } elseif ($definition instanceof FieldInterface) {
            return $definition->getResult($context);
        } elseif (is_array($definition)) {
            $result = [];
            foreach ($definition as $key => $value) {
                $result[$key] = $this->build($value, $context);
            }

            return new Record(
                $name === null ? 'record' : $name, 
                $result
            );
        } elseif (is_string($definition)) {
            if ($context !== null) {
                if (is_array($context)) {
                    if (array_key_exists($definition, $context)) {
                        return $context[$definition];
                    } else {
                        throw new RuntimeException('Referenced unknown key "' . $definition . '" in context');
                    }
                } elseif ($context instanceof \ArrayAccess) {
                    if ($context->offsetExists($definition)) {
                        return $context->offsetGet($definition);
                    } else {
                        throw new RuntimeException('Referenced unknown key "' . $definition . '" in context');
                    }
                } else {
                    throw new RuntimeException('Context must be either an array or instance of ArrayAccess');
                }
            } else {
                return $definition;
            }
        } else {
            return $definition;
        }
    }
689411
public function createSubject($context)
    {
        global $logger;
        //$copyContext = $this->copy($context);
        //$copyContext = $this->_ensureSecurityMgr($copyContext);
        //$copyContext = $this->_resolveSession($copyContext);
        //$copyContext = $this->_resolvePrincipals($copyContext);
        $subject     = $this->doCreateSubject($context);
        $this->_save($subject);

        return $subject;

    }
427617
public function createQuery($context = 'list')
    {
        if ($context === 'list') {
            /** @var $em \Doctrine\ORM\EntityManager */
            $em = $this->getModelManager()->getEntityManager($this->getClass());

            /** @var $cmd \Doctrine\Common\Persistence\Mapping\ClassMetadata */
            $cmd = $em->getMetadataFactory()->getMetadataFor($this->getClass());

            $queryBuilder = $em->createQueryBuilder();
            $queryBuilder
                ->select('n')
                ->from($this->getClass(), 'n');

            if ($cmd->hasField('root')) {
                $queryBuilder->orderBy('n.root, n.lft');
            } else {
                $queryBuilder->orderBy('n.lft');
            }

            return new ProxyQuery($queryBuilder);
        }
        return parent::createQuery($context);
    }
241269
public static function canEditPost(ContextInterface $context): bool
    {
        assert(self::reqGetResourceType($context) === Schema::TYPE);

        $userId = self::getCurrentUserIdentity($context);

        return $userId !== null;
    }
184829
public function goBegin(Context $context = null)
    {
        $id = $this->bind($context);
        return $this->getDBQueryBuilder($context)->go($id, 'begin');
    }
274658
protected function _actionCreate(ModelContext $context)
    {
        //Get the data
        $data = ModelContext::unbox($context->properties);

        if(!is_numeric(key($data))) {
            $data = array($data);
        }

        //Entity options
        $options = array(
            'data'            => $data,
            'identity_column' => $context->getIdentityKey()
        );

        return $this->getTable()->createRowset($options);
    }
508321
protected function _actionAdd(AnCommandContext $context)
    {
        $data = $context->data;

        return $this->getRepository()->create($data->toArray());
    }
626798
public function create($options, Context $context = null)
    {
        $validators = [];
        if (!empty($options['required'])) {
            $validators[] = new PresenceOf();
        }
        $type = ArrayHelper::fetch($options, 'type');
        if (isset($type)) {
            if ($type == 'datetime') {
                $validators[] = new Datetime([
                    'pattern' => ArrayHelper::fetch($options, 'pattern')
                ]);
            } elseif (isset(self::$TYPES[$type])) {
                $validators[] = (new self::$TYPES[$type]([]))->getValidator($this->form);
            } elseif ($type == 'array') {
                $validators[] = (new IsArray([
                    'element' => ArrayHelper::fetch($options, 'element')
                ], $context))->getValidator($this->form);
            } else {
                if ($context) {
                    $type = (new ClassResolver($this->form->getCache()))
                           ->resolve($type, $context->getDeclaringClass());
                }
                if (class_exists($type)) {
                    if (is_subclass_of($type, ValidatorInterface::class)) {
                        $validators[] = new $type($options);
                    } else {
                        $validators[] = new IsA($this->form, ['class' => $type]);
                    }
                } else {
                    if ($this->logger) {
                        $this->logger->warning("unknown validator type {$type}");
                    }
                }
            }
        }
        if (isset($options['min']) || isset($options['max'])) {
            $validators[] = new Range([
                'min' => ArrayHelper::fetch($options, 'min'),
                'max' => ArrayHelper::fetch($options, 'max'),
                'exclusiveMinimum' => ArrayHelper::fetch($options, 'exclusiveMinimum'),
                'exclusiveMaximum' => ArrayHelper::fetch($options, 'exclusiveMaximum')
            ]);
        }
        if (isset($options['minLength']) || isset($options['maxLength'])) {
            $validators[] = new StringLength([
                'min' => ArrayHelper::fetch($options, 'minLength'),
                'max' => ArrayHelper::fetch($options, 'maxLength')
            ]);
        }
        if (isset($options['enum'])) {
            if (is_array($options['enum'])) {
                $validators[] = new InclusionIn(['domain' => $options['enum']]);
            } else {
                $validators[] = (new Enum([
                    'model' => $options['enum'],
                    'attribute' => ArrayHelper::fetch($options, 'attribute'),
                ], $context))->getValidator($this->form);
            }
        }
        if (isset($options['pattern']) && $type != 'datetime') {
            $validators[] = new Regex([ 'pattern' => $options['pattern'] ]);
        }
        return $validators;
    }