Maps given LanguageCreateData object to a LanguageCreateStruct object.

@param LanguageCreateData $data

@return LanguageCreateStruct

@throws InvalidArgumentException
426806
public function reverseMap($data): LanguageCreateStruct
    {
        if (!$data instanceof LanguageCreateData) {
            throw new InvalidArgumentException('data', 'must be an instance of ' . LanguageCreateData::class);
        }

        return new LanguageCreateStruct([
            'languageCode' => $data->getLanguageCode(),
            'name' => $data->getName(),
            'enabled' => $data->isEnabled(),
        ]);
    }
784238
protected function create($data = null)
    {
        $method = '__'.str_replace(__CLASS__.'::', '', __METHOD__);

        if ($this->hasMethod($method) && is_callable([$this, $method])) {
            $arguments = func_get_args();
            if (empty($arguments)) {
                $result = $this->{$method}();
            } else {
                $result = call_user_func_array([$this, $method], $arguments);
            }

            return $result;
        }
    }
1297461
public static function createOrUpdateGraphNode($data)
    {
        // @todo this will be GraphNode soon
        if ($data instanceof GraphObject || $data instanceof GraphNode) {
            $data = array_dot($data->asArray());
        }

        $data = static::convertGraphNodeDateTimesToStrings($data);

        if (! isset($data['id'])) {
            throw new \InvalidArgumentException('Graph node id is missing');
        }

        $attributes = [static::getGraphNodeKeyName() => $data['id']];

        $graph_node = static::firstOrNewGraphNode($attributes);

        static::mapGraphNodeFieldNamesToDatabaseColumnNames($graph_node, $data);

        $graph_node->save();

        return $graph_node;
    }
499944
public function create($data)
    {
        $propertyDescriptor = new PropertyDescriptor();
        $propertyDescriptor->setNamespace(substr((string) $data->getFqsen(), 0, -strlen($data->getName()) - 3));
        $propertyDescriptor->setFullyQualifiedStructuralElementName($data->getFqsen());
        $propertyDescriptor->setName($data->getName());
        $propertyDescriptor->setVisibility((string) $data->getVisibility() ?: 'public');
        $propertyDescriptor->setStatic($data->isStatic());
        $propertyDescriptor->setDefault($data->getDefault());

        $this->assembleDocBlock($data->getDocBlock(), $propertyDescriptor);
        $propertyDescriptor->setLine($data->getLocation()->getLineNumber());

        return $propertyDescriptor;
    }
600045
public function create($data)
    {
        $propertyDescriptor = new PropertyDescriptor();
        $propertyDescriptor->setFullyQualifiedStructuralElementName($data->getName());
        $propertyDescriptor->setName($data->getShortName());
        $propertyDescriptor->setVisibility($data->getVisibility() ?: 'public');
        $propertyDescriptor->setStatic($data->isStatic());
        $propertyDescriptor->setDefault($data->getDefault());

        $this->assembleDocBlock($data->getDocBlock(), $propertyDescriptor);
        $propertyDescriptor->setLine($data->getLinenumber());

        return $propertyDescriptor;
    }
75465
protected function createStructure( array $data )
    {
        $structure = $this->getStructureFactory()
                          ->factory( $data );

        if ( $structure instanceof MapperAwareInterface )
        {
            $structure->setMapper( $this );
        }

        if ( $structure instanceof SiteInfoAwareInterface )
        {
            $structure->setSiteInfo( $this->getSiteInfo() );
        }

        if ( $structure instanceof ServiceLocatorAwareInterface )
        {
            $structure->setServiceLocator( $this->getServiceLocator() );
        }

        return $structure;
    }
1132693
private function createMultiLanguageController(stdClass $data)
    {
        $this->createFileFromTemplate([
            "destination"         => $data->controllerDestination,
            "templateDestination" => __DIR__ . '/../templates/service/controller/multiLanguage.hctpl',
            "content"             => [
                "namespace"                      => $data->controllerNamespace,
                "controllerName"                 => $data->controllerName,
                "acl_prefix"                     => $data->aclPrefix,
                "serviceURL"                     => $data->serviceURL,
                "translationsLocation"           => $data->translationsLocation,
                "serviceNameDotted"              => $this->stringWithDash($data->translationFilePrefix),
                "controllerNameDotted"           => $data->serviceRouteName,
                "adminListHeader"                => $this->getAdminListHeader($data),
                "formValidationName"             => $data->formValidationName,
                "translationsFormValidationName" => $data->formTranslationsValidationName,
                "functions"                      => replaceBrackets(file_get_contents(__DIR__ . '/../templates/service/controller/multilanguage/functions.hctpl'),
                    [
                        "modelName"      => $data->mainModel->modelName,
                        "modelNameSpace" => $data->modelNamespace,
                    ]),
                "inputData"                      => $this->getInputData($data),
                "useFiles"                       => $this->getUseFiles($data, true),
                "mainModelName"                  => $data->mainModel->modelName,
                "searchableFields"               => $this->getSearchableFields($data),
                "searchableFieldsTranslations"   => $this->getSearchableFields($data, true),
            ],
        ]);

        return $data->controllerDestination;
    }
916994
public function updateLanguage(
        LanguageUpdateData $data,
        ?string $name = null
    ): FormInterface {
        $name = $name ?: sprintf('update-language-%d', $data->getLanguage()->id);

        return $this->formFactory->createNamed($name, LanguageUpdateType::class, $data);
    }
963448
public function create($data)
    {
        $classDescriptor = new ClassDescriptor();

        $classDescriptor->setFullyQualifiedStructuralElementName($data->getName());
        $classDescriptor->setName($data->getShortName());
        $classDescriptor->setPackage($this->extractPackageFromDocBlock($data->getDocBlock()) ?: '');
        $classDescriptor->setLine($data->getLinenumber());
        $classDescriptor->setParent($data->getParentClass());
        $classDescriptor->setAbstract($data->isAbstract());
        $classDescriptor->setFinal($data->isFinal());

        // Reflection library formulates namespace as global but this is not wanted for phpDocumentor itself
        $classDescriptor->setNamespace(
            '\\' . (strtolower($data->getNamespace()) == 'global' ? '' :$data->getNamespace())
        );

        foreach ($data->getInterfaces() as $interfaceClassName) {
            $classDescriptor->getInterfaces()->set($interfaceClassName, $interfaceClassName);
        }

        $fqcn = $classDescriptor->getFullyQualifiedStructuralElementName();
        $namespace = substr($fqcn, 0, strrpos($fqcn, '\\'));
        $classDescriptor->setNamespace($namespace);

        $this->assembleDocBlock($data->getDocBlock(), $classDescriptor);

        $this->addConstants($data->getConstants(), $classDescriptor);
        $this->addProperties($data->getProperties(), $classDescriptor);
        $this->addMethods($data->getMethods(), $classDescriptor);
        $this->addUses($data->getTraits(), $classDescriptor);

        return $classDescriptor;
    }
143069
public function addData($data) {
        if (\is_string($data)) {
            $this->addDataSql($data);
        } elseif (\is_array($data)) {
            $this->addDataArray($data);
        } elseif (\is_object($data)) {
            $this->addDataObjectCollection($data);
        } elseif (\is_resource($data)) {
            $this->addDataQueryResource($data);
        } else {
            throw new InvalidArgumentException('Unsupported data type.');
        }
        return $this;
    }
417008
public function create($data)
    {
        $fileDescriptor = new FileDescriptor($data->getHash());

        $fileDescriptor->setPackage(
            $this->extractPackageFromDocBlock($data->getDocBlock()) ?: $data->getDefaultPackageName()
        );

        $fileDescriptor->setName(basename($data->getFilename()));
        $fileDescriptor->setPath($data->getFilename());
        $fileDescriptor->setSource($data->getContents());
        $fileDescriptor->setIncludes(new Collection($data->getIncludes()));
        $fileDescriptor->setNamespaceAliases(new Collection($data->getNamespaceAliases()));

        $this->assembleDocBlock($data->getDocBlock(), $fileDescriptor);
        $this->overridePackageTag($data, $fileDescriptor);

        $this->addMarkers($data->getMarkers(), $fileDescriptor);
        $this->addConstants($data->getConstants(), $fileDescriptor);
        $this->addFunctions($data->getFunctions(), $fileDescriptor);
        $this->addClasses($data->getClasses(), $fileDescriptor);
        $this->addInterfaces($data->getInterfaces(), $fileDescriptor);
        $this->addTraits($data->getTraits(), $fileDescriptor);

        return $fileDescriptor;
    }
1014677
public function addOrRestore(array $data): \Translations\Model\Entity\Language
    {
        if (empty($data['code'])) {
            throw new InvalidArgumentException("Language data is missing 'code' key");
        }

        if (empty($data['is_rtl'])) {
            $data['is_rtl'] = $this->isRtl($data['code']);
        }

        if (empty($data['name'])) {
            $data['name'] = $this->getName($data['code']);
        }

        /**
         * @var \Cake\Datasource\EntityInterface $deletedEntity
         */
        $deletedEntity = $this->find('onlyTrashed')
            ->where(['code' => $data['code']])
            ->first();

        if (!empty($deletedEntity)) {
            return $this->restoreTrash($deletedEntity);
        }

        $newEntity = $this->newEntity();
        $newEntity = $this->patchEntity($newEntity, $data);
        /**
         * @var \Translations\Model\Entity\Language $result
         */
        $result = $this->save($newEntity);

        return $result;
    }
1174384
public function setData($data)
    {
        if (!$data instanceof \SimpleXMLElement) {
            throw new \InvalidArgumentException(__METHOD__ . ' argument should be instance of ' . \SimpleXMLElement::class);
        }

        $this->data = $data;

        return $this;
    }
313203
public function deleteLanguage(
        LanguageDeleteData $data,
        ?string $name = null
    ): FormInterface {
        $name = $name ?: sprintf('delete-language-%d', $data->getLanguage()->id);

        return $this->formFactory->createNamed($name, LanguageDeleteType::class, $data);
    }
403152
public function create($data)
    {
        $interfaceDescriptor = new InterfaceDescriptor();

        $interfaceDescriptor->setFullyQualifiedStructuralElementName($data->getName());
        $interfaceDescriptor->setName($data->getShortName());
        $interfaceDescriptor->setLine($data->getLinenumber());
        $interfaceDescriptor->setPackage($this->extractPackageFromDocBlock($data->getDocBlock()) ?: '');

        // Reflection library formulates namespace as global but this is not wanted for phpDocumentor itself
        $interfaceDescriptor->setNamespace(
            '\\' . (strtolower($data->getNamespace()) == 'global' ? '' :$data->getNamespace())
        );

        $this->assembleDocBlock($data->getDocBlock(), $interfaceDescriptor);
        $this->addConstants($data->getConstants(), $interfaceDescriptor);
        $this->addMethods($data->getMethods(), $interfaceDescriptor);

        foreach ($data->getParentInterfaces() as $interfaceClassName) {
            $interfaceDescriptor->getParent()->set($interfaceClassName, $interfaceClassName);
        }

        return $interfaceDescriptor;
    }
520185
protected function buildLanguage(array $siteData)
    {
        if (!empty($siteData['language']) && $siteData['language'] instanceof Language) {
            return $siteData['language'];
        }

        if (!empty($siteData['languageIso6392t'])) {
            $language = $this->languageRepository->findOneBy(
                ['iso639_2t' => $siteData['languageIso6392t']]
            );

            if (empty($language)) {
                throw new LanguageNotFoundException("Language {$siteData['languageIso6392t']} could not be found.");
            }

            return $language;
        }

        return null;
    }
899015
public function create($data)
    {
        $methodDescriptor = new MethodDescriptor();
        $methodDescriptor->setNamespace(
            substr(
                (string) $data->getFqsen(),
                0,
                -strlen($data->getName()) - 4
            )
        );
        $this->mapReflectorToDescriptor($data, $methodDescriptor);

        $this->assembleDocBlock($data->getDocBlock(), $methodDescriptor);
        $this->addArguments($data, $methodDescriptor);
        $this->addVariadicArgument($data, $methodDescriptor);

        return $methodDescriptor;
    }