diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0139f99 --- /dev/null +++ b/.gitignore @@ -0,0 +1,55 @@ +###################### +# Compiled source # +###################### +*.com +*.class +*.dll +*.exe +*.o +*.so + +###################### +# Packages # +###################### +# it's better to unpack these files and commit the raw source +# git has its own built in compression methods +*.7z +*.dmg +*.gz +*.iso +*.jar + +###################### +# Logs and databases # +###################### +*.log + +###################### +# Global # +###################### +.DS_Store +.DS_Store\? +._* +.Spotlight-V100 +.Trashes +Icon\? +*.sublime-workspace +*.sublime-project +atlassian-ide-plugin.xml +.idea/ +.project +ehthumbs.db +Thumbs.db +Vagrantfile +.vagrant +php-cgi.core +.sass-cache + +# codeception (only stage *.dist.yml config files) +/codeception.yml +/tests/codeception.yml +/tests/*.suite.yml +/tests/_output/* +/tests/_data/* +!/tests/_data/.gitkeep +/tests/_support/_generated/* \ No newline at end of file diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..85e1035 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,40 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge +In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. + +## Our Standards +Examples of behavior that contributes to creating a positive environment include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a professional setting + +## Our Responsibilities +Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. + +## Scope +This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. + +## Enforcement +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at support@dachcom.ch. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. + +## Attribution +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..5c9e622 --- /dev/null +++ b/ISSUE_TEMPLATE.md @@ -0,0 +1,12 @@ +| Q | A +| ---------------- | ----- +| Bug report? | yes/no +| Feature request? | yes/no +| BC Break report? | yes/no +| RFC? | yes/no + + \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..f4c2de3 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,22 @@ +# License +Copyright (C) 2017 DACHCOM.DIGITAL + +This software is available under the GNU General Public License version 3 (GPLv3). + +### GNU General Public License version 3 (GPLv3) +If you decide to choose the GPLv3 license, you must comply with the following terms: + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +[GNU General Public License](lhttps://www.gnu.org/licenses/gpl-3.0.en.html) \ No newline at end of file diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..d6cb8ba --- /dev/null +++ b/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,12 @@ +| Q | A +| ------------- | --- +| Bug fix? | yes/no +| New feature? | yes/no +| BC breaks? | no +| Deprecations? | yes/no +| Fixed tickets | #... + + diff --git a/README.md b/README.md new file mode 100644 index 0000000..47f030a --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Dynamic Search | Data Provider: Trinity Data + +Crawl Pimcore Data: `assets`, `documents` and `objects`. diff --git a/composer.json b/composer.json new file mode 100755 index 0000000..44d8f2d --- /dev/null +++ b/composer.json @@ -0,0 +1,31 @@ +{ + "name": "dachcom-digital/dynamic-search-data-provider-trinity", + "type": "pimcore-bundle", + "license": "GPL-3.0+", + "description": "", + "keywords": ["pimcore", "search", "dynamic-search", "data-provider","trinity", "assets", "documents", "objects"], + "homepage": "https://github.com/dachcom-digital/pimcore-dynamic-search-data-provider-trinity", + "authors": [ + { + "name": "DACHCOM.DIGITAL Stefan Hagspiel", + "email": "shagspiel@dachcom.ch", + "homepage": "http://www.dachcom.com/", + "role": "Developer" + } + ], + "autoload": { + "psr-4": { + "DsTrinityDataBundle\\": "src/DsTrinityDataBundle" + } + }, + + "extra": { + "pimcore": { + "bundles": [ + "DsTrinityDataBundle\\DsTrinityDataBundle" + ] + } + }, + "require": { + } +} \ No newline at end of file diff --git a/src/DsTrinityDataBundle/Configuration/Configuration.php b/src/DsTrinityDataBundle/Configuration/Configuration.php new file mode 100644 index 0000000..8db6e82 --- /dev/null +++ b/src/DsTrinityDataBundle/Configuration/Configuration.php @@ -0,0 +1,29 @@ +config = $config; + } + + /** + * @param string $slot + * + * @return mixed + */ + public function get($slot) + { + return $this->config[$slot]; + } +} diff --git a/src/DsTrinityDataBundle/Configuration/ConfigurationInterface.php b/src/DsTrinityDataBundle/Configuration/ConfigurationInterface.php new file mode 100644 index 0000000..f64dfbe --- /dev/null +++ b/src/DsTrinityDataBundle/Configuration/ConfigurationInterface.php @@ -0,0 +1,13 @@ +findTaggedServiceIds('ds_trinity_data.data_builder', true) as $id => $tags) { + $definition = $container->getDefinition(DataBuilderRegistry::class); + foreach ($tags as $attributes) { + $definition->addMethodCall('register', [new Reference($id), $attributes['identifier'], $attributes['type']]); + } + } + } +} \ No newline at end of file diff --git a/src/DsTrinityDataBundle/DependencyInjection/Configuration.php b/src/DsTrinityDataBundle/DependencyInjection/Configuration.php new file mode 100644 index 0000000..35b3938 --- /dev/null +++ b/src/DsTrinityDataBundle/DependencyInjection/Configuration.php @@ -0,0 +1,17 @@ +root('ds_trinity_data'); + + return $treeBuilder; + } +} \ No newline at end of file diff --git a/src/DsTrinityDataBundle/DependencyInjection/DsTrinityDataExtension.php b/src/DsTrinityDataBundle/DependencyInjection/DsTrinityDataExtension.php new file mode 100644 index 0000000..c657f8d --- /dev/null +++ b/src/DsTrinityDataBundle/DependencyInjection/DsTrinityDataExtension.php @@ -0,0 +1,30 @@ +processConfiguration($configuration, $configs); + + $loader = new YamlFileLoader($container, new FileLocator([__DIR__ . '/../Resources/config'])); + $loader->load('services.yml'); + + $configManagerDefinition = $container->getDefinition(BundleConfiguration::class); + $configManagerDefinition->addMethodCall('setConfig', [$config]); + } +} \ No newline at end of file diff --git a/src/DsTrinityDataBundle/DsTrinityDataBundle.php b/src/DsTrinityDataBundle/DsTrinityDataBundle.php new file mode 100644 index 0000000..aaf29d6 --- /dev/null +++ b/src/DsTrinityDataBundle/DsTrinityDataBundle.php @@ -0,0 +1,35 @@ +addCompilerPass(new DataBuilderPass()); + } + + /** + * {@inheritdoc} + */ + protected function getComposerPackageName(): string + { + return self::PACKAGE_NAME; + } +} diff --git a/src/DsTrinityDataBundle/DsTrinityDataEvents.php b/src/DsTrinityDataBundle/DsTrinityDataEvents.php new file mode 100644 index 0000000..10a2345 --- /dev/null +++ b/src/DsTrinityDataBundle/DsTrinityDataEvents.php @@ -0,0 +1,8 @@ +eventDispatcher = $eventDispatcher; + $this->dataProvider = $dataProvider; + } + + /** + * {@inheritDoc} + */ + public function setLogger(LoggerInterface $logger) + { + $this->logger = $logger; + } + + /** + * {@inheritDoc} + */ + public function setOptions(array $configuration) + { + $this->configuration = $configuration; + } + + /** + * {@inheritDoc} + */ + public function warmUp(ContextDataInterface $contextData) + { + } + + /** + * {@inheritDoc} + */ + public function coolDown(ContextDataInterface $contextData) + { + } + + /** + * {@inheritDoc} + */ + public function cancelledShutdown(ContextDataInterface $contextData) + { + } + + /** + * {@inheritDoc} + */ + public function emergencyShutdown(ContextDataInterface $contextData) + { + } + + /** + * {@inheritDoc} + */ + public function execute(ContextDataInterface $contextData) + { + $runtimeOptions = $this->validateRuntimeOptions($contextData->getDispatchType(), $contextData->getRuntimeOptions()); + + $this->dataProvider->setLogger($this->logger); + $this->dataProvider->setContextName($contextData->getName()); + $this->dataProvider->setContextDispatchType($contextData->getDispatchType()); + $this->dataProvider->setIndexOptions($this->configuration); + $this->dataProvider->setRuntimeOptions($runtimeOptions); + + if ($contextData->getDispatchType() === ContextDataInterface::CONTEXT_DISPATCH_TYPE_INDEX) { + $this->dataProvider->fetchIndexData(); + } elseif ($contextData->getDispatchType() === ContextDataInterface::CONTEXT_DISPATCH_TYPE_INSERT) { + $this->dataProvider->fetchInsertData(); + } elseif ($contextData->getDispatchType() === ContextDataInterface::CONTEXT_DISPATCH_TYPE_UPDATE) { + $this->dataProvider->fetchUpdateData(); + } + } + + /** + * {@inheritDoc} + */ + public function configureOptions(OptionsResolver $resolver) + { + $defaults = [ + 'index_asset' => false, + 'asset_data_builder_identifier' => 'default', + 'asset_types' => Asset::$types, + 'index_object' => false, + 'object_data_builder_identifier' => 'default', + 'object_types' => DataObject::$types, + 'object_class_names' => [], + 'object_ignore_unpublished' => true, + 'index_document' => false, + 'document_data_builder_identifier' => 'default', + 'document_types' => Document::$types, + 'document_ignore_unpublished' => true, + ]; + + $resolver->setDefaults($defaults); + $resolver->setRequired(array_keys($defaults)); + } + + /** + * @param string $contextDispatchType + * @param array $runtimeOptions + * + * @return array + * @throws ProviderException + */ + protected function validateRuntimeOptions(string $contextDispatchType, array $runtimeOptions = []) + { + $errorMessage = null; + + switch ($contextDispatchType) { + case ContextDataInterface::CONTEXT_DISPATCH_TYPE_UPDATE: + if (!isset($runtimeOptions['id']) || empty($runtimeOptions['id'])) { + $errorMessage = 'no "id" runtime option given. value cannot be empty'; + } + break; + case ContextDataInterface::CONTEXT_DISPATCH_TYPE_INSERT: + if (!isset($runtimeOptions['path']) || !is_string($runtimeOptions['path'])) { + $errorMessage = 'no "path" runtime option given. needs to be a valid string'; + } + break; + case ContextDataInterface::CONTEXT_DISPATCH_TYPE_DELETE: + if (!isset($runtimeOptions['id']) || empty($runtimeOptions['id'])) { + $errorMessage = 'no "id" runtime option given. value cannot be empty'; + } + break; + } + + if ($errorMessage !== null) { + throw new ProviderException(sprintf('Runtime Options validation failed. Error was: %s', $errorMessage), DsTrinityDataBundle::PROVIDER_NAME); + } + + return $runtimeOptions; + } + +} \ No newline at end of file diff --git a/src/DsTrinityDataBundle/Registry/DataBuilderRegistry.php b/src/DsTrinityDataBundle/Registry/DataBuilderRegistry.php new file mode 100644 index 0000000..9c01ffa --- /dev/null +++ b/src/DsTrinityDataBundle/Registry/DataBuilderRegistry.php @@ -0,0 +1,53 @@ +builder[$type])) { + $this->builder[$type] = []; + } + + $this->builder[$type][$identifier] = $service; + } + + /** + * {@inheritdoc} + */ + public function getByTypeAndIdentifier(string $type, string $identifier) + { + return $this->builder[$type][$identifier]; + } +} \ No newline at end of file diff --git a/src/DsTrinityDataBundle/Registry/DataBuilderRegistryInterface.php b/src/DsTrinityDataBundle/Registry/DataBuilderRegistryInterface.php new file mode 100644 index 0000000..42a1a34 --- /dev/null +++ b/src/DsTrinityDataBundle/Registry/DataBuilderRegistryInterface.php @@ -0,0 +1,16 @@ +addConditionParam('id = ?', $id); + } + + $this->addAssetTypeRestriction($list, $allowedTypes); + + return $list->getAssets(); + } + + /** + * @param Asset\Listing $listing + * @param array $allowedTypes + * + * @return Asset\Listing + */ + protected function addAssetTypeRestriction(Asset\Listing $listing, array $allowedTypes) + { + if (count($allowedTypes) === 0) { + return $listing; + } + + $quotedTypes = []; + foreach ($allowedTypes as $cName) { + $quotedTypes[] = \Pimcore\Db::get()->quote($cName); + } + + $listing->addConditionParam(sprintf('type in(%s)', implode(',', $quotedTypes)), ''); + + return $listing; + } +} \ No newline at end of file diff --git a/src/DsTrinityDataBundle/Service/Builder/DataBuilderInterface.php b/src/DsTrinityDataBundle/Service/Builder/DataBuilderInterface.php new file mode 100644 index 0000000..02b2059 --- /dev/null +++ b/src/DsTrinityDataBundle/Service/Builder/DataBuilderInterface.php @@ -0,0 +1,13 @@ +setUnpublished(true); + } + + if ($id !== null) { + $list->addConditionParam('id = ?', $id); + } + + $this->addDocumentTypeRestriction($list, $allowedTypes); + + return $list->getDocuments(); + } + + /** + * @param Document\Listing $listing + * @param array $allowedTypes + * + * @return Document\Listing + */ + protected function addDocumentTypeRestriction(Document\Listing $listing, array $allowedTypes) + { + if (count($allowedTypes) === 0) { + return $listing; + } + + $quotedTypes = []; + foreach ($allowedTypes as $cName) { + $quotedTypes[] = \Pimcore\Db::get()->quote($cName); + } + + $listing->addConditionParam(sprintf('type in(%s)', implode(',', $quotedTypes)), ''); + + return $listing; + } +} \ No newline at end of file diff --git a/src/DsTrinityDataBundle/Service/Builder/ObjectListBuilder.php b/src/DsTrinityDataBundle/Service/Builder/ObjectListBuilder.php new file mode 100644 index 0000000..64f23ae --- /dev/null +++ b/src/DsTrinityDataBundle/Service/Builder/ObjectListBuilder.php @@ -0,0 +1,73 @@ +setUnpublished(true); + } + + if ($id !== null) { + $list->addConditionParam('o_id = ?', $id); + } + + $this->addObjectTypeRestriction($list, $allowedTypes); + $this->addClassNameRestriction($list, $allowedClasses); + + return $list->getObjects(); + } + + /** + * @param DataObject\Listing $listing + * @param array $allowedTypes + * + * @return DataObject\Listing + */ + protected function addObjectTypeRestriction(DataObject\Listing $listing, array $allowedTypes) + { + if (count($allowedTypes) === 0) { + return $listing; + } + + $listing->setObjectTypes($allowedTypes); + + return $listing; + } + + /** + * @param DataObject\Listing $listing + * @param array $allowedClasses + * + * @return DataObject\Listing + */ + protected function addClassNameRestriction(DataObject\Listing $listing, array $allowedClasses) + { + if (count($allowedClasses) === 0) { + return $listing; + } + + $quotedClassNames = []; + foreach ($allowedClasses as $cName) { + $quotedClassNames[] = \Pimcore\Db::get()->quote($cName); + } + + $listing->addConditionParam(sprintf('o_className in(%s)', implode(',', $quotedClassNames)), ''); + + return $listing; + } +} \ No newline at end of file diff --git a/src/DsTrinityDataBundle/Service/DataProviderService.php b/src/DsTrinityDataBundle/Service/DataProviderService.php new file mode 100644 index 0000000..862c975 --- /dev/null +++ b/src/DsTrinityDataBundle/Service/DataProviderService.php @@ -0,0 +1,211 @@ +eventDispatcher = $eventDispatcher; + $this->dataBuilderRegistry = $dataBuilderRegistry; + } + + /** + * {@inheritDoc} + */ + public function setLogger(LoggerInterface $logger) + { + $this->logger = $logger; + } + + /** + * {@inheritDoc} + */ + public function setContextName(string $contextName) + { + $this->contextName = $contextName; + } + + /** + * {@inheritDoc} + */ + public function setContextDispatchType(string $dispatchType) + { + $this->contextDispatchType = $dispatchType; + } + + /** + * {@inheritDoc} + */ + public function setIndexOptions(array $indexOptions) + { + $this->indexOptions = $indexOptions; + } + + /** + * {@inheritDoc} + */ + public function setRuntimeOptions(array $runtimeOptions) + { + $this->runtimeOptions = $runtimeOptions; + } + + /** + * {@inheritDoc} + */ + public function fetchIndexData() + { + foreach (['asset', 'document', 'object'] as $type) { + $this->fetchByType($type); + } + + } + + /** + * {@inheritDoc} + */ + public function fetchInsertData() + { + $id = $this->runtimeOptions['id']; + $indexId = explode('_', $id); + + $elementType = $indexId[0]; + $elementId = (int) $indexId[1]; + + if (!in_array($elementType, ['asset', 'document', 'object'])) { + $this->log('error', sprintf('cannot insert data from identifier "%s". wrong type "%s" given', $id, $elementType)); + return; + } + + $this->fetchByType($elementType, $elementId); + + } + + /** + * {@inheritDoc} + */ + public function fetchUpdateData() + { + $id = $this->runtimeOptions['id']; + $indexId = explode('_', $id); + + $elementType = $indexId[0]; + $elementId = (int) $indexId[1]; + + if (!in_array($elementType, ['asset', 'document', 'object'])) { + $this->log('error', sprintf('cannot insert data from identifier "%s". wrong type "%s" given', $id, $elementType)); + return; + } + + $this->fetchByType($elementType, $elementId); + } + + /** + * @param string $type + * @param null $id + */ + protected function fetchByType(string $type, $id = null) + { + $builder = null; + + if ($this->indexOptions[sprintf('index_%s', $type)] === false) { + return; + } + + $builderIdentifier = sprintf('%s_data_builder_identifier', $type); + $builder = $this->dataBuilderRegistry->getByTypeAndIdentifier($type, $this->indexOptions[$builderIdentifier]); + + if (!$builder instanceof DataBuilderInterface) { + $this->log('error', sprintf('could not resolve data builder for type "%s"', $type)); + return; + } + + $options = $this->getTypeOptions($type); + $options['id'] = $id; + + $elements = $builder->build($options); + + $this->dispatchData($elements); + } + + /** + * @param string $level + * @param string $message + */ + protected function log($level, $message) + { + $this->logger->log($level, $message, DsTrinityDataBundle::PROVIDER_NAME, $this->contextName); + } + + /** + * @param $elements + */ + protected function dispatchData(array $elements) + { + foreach ($elements as $element) { + $newDataEvent = new NewDataEvent($this->contextDispatchType, $this->contextName, $element, $this->runtimeOptions); + $this->eventDispatcher->dispatch(DynamicSearchEvents::NEW_DATA_AVAILABLE, $newDataEvent); + } + } + + /** + * @param string $type + * + * @return array + */ + protected function getTypeOptions(string $type) + { + return array_filter($this->indexOptions, function ($option) use ($type) { + return strpos($option, sprintf('%s_', $type)) !== false; + }, ARRAY_FILTER_USE_KEY); + } +} \ No newline at end of file diff --git a/src/DsTrinityDataBundle/Service/DataProviderServiceInterface.php b/src/DsTrinityDataBundle/Service/DataProviderServiceInterface.php new file mode 100644 index 0000000..47d4556 --- /dev/null +++ b/src/DsTrinityDataBundle/Service/DataProviderServiceInterface.php @@ -0,0 +1,24 @@ +hasDataAttribute('type')) { + return null; + } + + $data = $transformedData->getDataAttribute('data'); + $type = $transformedData->getDataAttribute('type'); + $dataType = $transformedData->getDataAttribute('data_type'); + + if (!$data instanceof ElementInterface) { + return null; + } + + $value = sprintf('%s_%d', $type, $data->getId()); + + return new FieldContainer($value); + + } +} \ No newline at end of file diff --git a/src/DsTrinityDataBundle/Transformer/Field/ObjectGetterExtractor.php b/src/DsTrinityDataBundle/Transformer/Field/ObjectGetterExtractor.php new file mode 100644 index 0000000..7f55f13 --- /dev/null +++ b/src/DsTrinityDataBundle/Transformer/Field/ObjectGetterExtractor.php @@ -0,0 +1,50 @@ +setRequired(['argument']); + $resolver->setAllowedTypes('argument', ['string']); + $resolver->setDefaults([ + 'argument' => 'id' + ]); + } + + /** + * {@inheritDoc} + */ + public function transformData(array $options, string $dispatchTransformerName, DataContainerInterface $transformedData): ?FieldContainerInterface + { + if (!$transformedData->hasDataAttribute('type')) { + return null; + } + + $data = $transformedData->getDataAttribute('data'); + $type = $transformedData->getDataAttribute('type'); + $dataType = $transformedData->getDataAttribute('data_type'); + + if (!method_exists($data, $options['argument'])) { + return null; + } + + $value = call_user_func([$data, $options['argument']]); + if (!is_string($value)) { + return null; + } + + return new FieldContainer($value); + + } +} \ No newline at end of file diff --git a/src/DsTrinityDataBundle/Transformer/TrinityDataTransformer.php b/src/DsTrinityDataBundle/Transformer/TrinityDataTransformer.php new file mode 100644 index 0000000..b585afc --- /dev/null +++ b/src/DsTrinityDataBundle/Transformer/TrinityDataTransformer.php @@ -0,0 +1,86 @@ +logger = $logger; + } + + /** + * {@inheritDoc} + */ + public function transformData(ContextDataInterface $contextData, $data): ?DataContainerInterface + { + $this->contextData = $contextData; + + $type = null; + $dataType = null; + + if ($data instanceof Asset) { + $type = 'asset'; + $dataType = $data->getType(); + } elseif ($data instanceof Document) { + $type = 'document'; + $dataType = $data->getType(); + } elseif ($data instanceof DataObject\Concrete) { + $type = 'object'; + $dataType = $data->getType(); + } + + return new DataContainer([ + 'type' => $type, + 'data_type' => $dataType, + 'data' => $data + ]); + } + + /** + * @param string $level + * @param string $message + */ + protected function log($level, $message) + { + $this->logger->log($level, $message, 'trinity_data_transformer', $this->contextData->getName()); + } +} \ No newline at end of file