Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK: Refactor absolute namespaces in Neos / Service #732

Merged
merged 2 commits into from Sep 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -14,8 +14,12 @@
use TYPO3\Flow\Annotations as Flow;
use TYPO3\Flow\Object\ObjectManagerInterface;
use TYPO3\Flow\Persistence\PersistenceManagerInterface;
use TYPO3\Flow\Property\PropertyMappingConfiguration;
use TYPO3\Flow\Reflection\ObjectAccess;
use TYPO3\Flow\Security\Authorization\PrivilegeManagerInterface;
use TYPO3\Flow\Utility\TypeHandling;
use TYPO3\Media\Domain\Model\Asset;
use TYPO3\Media\Domain\Model\ImageInterface;
use TYPO3\Neos\Domain\Service\ContentContext;
use TYPO3\Neos\TypeConverter\EntityToIdentityConverter;
use TYPO3\TYPO3CR\Domain\Model\Node;
Expand Down Expand Up @@ -105,7 +109,6 @@ public function wrapContentObject(NodeInterface $node, $typoScriptPath, $content
return $content;
}


if ($node->isRemoved()) {
$classNames[] = 'neos-contentelement-removed';
}
Expand Down Expand Up @@ -261,25 +264,25 @@ protected function getNodeProperty(NodeInterface $node, $propertyName, &$dataTyp
}
}

if ($propertyValue instanceof \TYPO3\Media\Domain\Model\ImageInterface) {
$propertyMappingConfiguration = new \TYPO3\Flow\Property\PropertyMappingConfiguration();
if ($propertyValue instanceof ImageInterface) {
$propertyMappingConfiguration = new PropertyMappingConfiguration();
return json_encode($this->entityToIdentityConverter->convertFrom($propertyValue, 'array', array(), $propertyMappingConfiguration));
}

// Serialize an Asset to JSON (the NodeConverter expects JSON for object type properties)
if ($dataType === ltrim('TYPO3\Media\Domain\Model\Asset', '\\') && $propertyValue !== null) {
if ($propertyValue instanceof \TYPO3\Media\Domain\Model\Asset) {
if ($dataType === ltrim(Asset::class, '\\') && $propertyValue !== null) {
if ($propertyValue instanceof Asset) {
return json_encode($this->persistenceManager->getIdentifierByObject($propertyValue));
}
}

// Serialize an array of Assets to JSON
if (is_array($propertyValue)) {
$parsedType = \TYPO3\Flow\Utility\TypeHandling::parseType($dataType);
if ($parsedType['elementType'] === ltrim('TYPO3\Media\Domain\Model\Asset', '\\')) {
$parsedType = TypeHandling::parseType($dataType);
if ($parsedType['elementType'] === ltrim(Asset::class, '\\')) {
$convertedValues = array();
foreach ($propertyValue as $singlePropertyValue) {
if ($singlePropertyValue instanceof \TYPO3\Media\Domain\Model\Asset) {
if ($singlePropertyValue instanceof Asset) {
$convertedValues[] = $this->persistenceManager->getIdentifierByObject($singlePropertyValue);
}
}
Expand Down
Expand Up @@ -12,8 +12,10 @@
*/

use TYPO3\Flow\Annotations as Flow;
use TYPO3\Flow\Mvc\View\JsonView;
use TYPO3\Flow\Object\ObjectManagerInterface;
use TYPO3\Flow\Reflection\ObjectAccess;
use TYPO3\Flow\Reflection\ReflectionService;
use TYPO3\Neos\Exception as NeosException;
use TYPO3\Neos\Service\DataSource\DataSourceInterface;
use TYPO3\TYPO3CR\Domain\Model\NodeInterface;
Expand All @@ -30,7 +32,7 @@ class DataSourceController extends AbstractServiceController
* @var array
*/
protected $viewFormatToObjectNameMap = array(
'json' => 'TYPO3\Flow\Mvc\View\JsonView'
'json' => JsonView::class
);

/**
Expand Down Expand Up @@ -72,10 +74,10 @@ public function indexAction($dataSourceIdentifier, NodeInterface $node = null)
*/
public static function getDataSources($objectManager)
{
$reflectionService = $objectManager->get('TYPO3\Flow\Reflection\ReflectionService');
$reflectionService = $objectManager->get(ReflectionService::class);

$dataSources = array();
$dataSourceClassNames = $reflectionService->getAllImplementationClassNamesForInterface('TYPO3\Neos\Service\DataSource\DataSourceInterface');
$dataSourceClassNames = $reflectionService->getAllImplementationClassNamesForInterface(DataSourceInterface::class);
/** @var $dataSourceClassName DataSourceInterface */
foreach ($dataSourceClassNames as $dataSourceClassName) {
$identifier = $dataSourceClassName::getIdentifier();
Expand Down
Expand Up @@ -13,7 +13,10 @@

use TYPO3\Flow\Annotations as Flow;
use TYPO3\Eel\FlowQuery\FlowQuery;
use TYPO3\Flow\Property\TypeConverter\PersistentObjectConverter;
use TYPO3\Neos\Domain\Repository\DomainRepository;
use TYPO3\Neos\Domain\Service\NodeSearchService;
use TYPO3\Neos\Service\NodeOperations;
use TYPO3\Neos\Service\View\NodeView;
use TYPO3\TYPO3CR\Domain\Factory\NodeFactory;
use TYPO3\TYPO3CR\Domain\Model\NodeInterface;
Expand Down Expand Up @@ -42,8 +45,8 @@ class NodeController extends AbstractServiceController
* @var array
*/
protected $viewFormatToObjectNameMap = array(
'html' => 'TYPO3\Neos\Service\View\NodeView',
'json' => 'TYPO3\Neos\Service\View\NodeView'
'html' => NodeView::class,
'json' => NodeView::class
);

/**
Expand Down Expand Up @@ -86,13 +89,13 @@ class NodeController extends AbstractServiceController

/**
* @Flow\Inject
* @var \TYPO3\Neos\Service\NodeOperations
* @var NodeOperations
*/
protected $nodeOperations;

/**
* @Flow\Inject
* @var \TYPO3\Neos\Domain\Repository\DomainRepository
* @var DomainRepository
*/
protected $domainRepository;

Expand All @@ -104,7 +107,7 @@ class NodeController extends AbstractServiceController
protected function initializeAction()
{
if ($this->arguments->hasArgument('referenceNode')) {
$this->arguments->getArgument('referenceNode')->getPropertyMappingConfiguration()->setTypeConverterOption('TYPO3\TYPO3CR\TypeConverter\NodeConverter', NodeConverter::REMOVED_CONTENT_SHOWN, true);
$this->arguments->getArgument('referenceNode')->getPropertyMappingConfiguration()->setTypeConverterOption(NodeConverter::class, NodeConverter::REMOVED_CONTENT_SHOWN, true);
}
$this->uriBuilder->setRequest($this->request->getMainRequest());
if (in_array($this->request->getControllerActionName(), array('update', 'updateAndRender'), true)) {
Expand All @@ -113,8 +116,8 @@ protected function initializeAction()
$propertyMappingConfiguration->allowOverrideTargetType();
$propertyMappingConfiguration->allowAllProperties();
$propertyMappingConfiguration->skipUnknownProperties();
$propertyMappingConfiguration->setTypeConverterOption('TYPO3\Flow\Property\TypeConverter\PersistentObjectConverter', \TYPO3\Flow\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_MODIFICATION_ALLOWED, true);
$propertyMappingConfiguration->setTypeConverterOption('TYPO3\Flow\Property\TypeConverter\PersistentObjectConverter', \TYPO3\Flow\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED, true);
$propertyMappingConfiguration->setTypeConverterOption(PersistentObjectConverter::class, PersistentObjectConverter::CONFIGURATION_MODIFICATION_ALLOWED, true);
$propertyMappingConfiguration->setTypeConverterOption(PersistentObjectConverter::class, PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED, true);
}
}

Expand Down
Expand Up @@ -12,7 +12,14 @@
*/

use TYPO3\Flow\Annotations as Flow;
use TYPO3\Flow\Property\PropertyMapper;
use TYPO3\Flow\Property\PropertyMappingConfigurationBuilder;
use TYPO3\Neos\Service\PublishingService;
use TYPO3\Neos\Service\View\NodeView;
use TYPO3\TYPO3CR\Domain\Model\NodeInterface;
use TYPO3\TYPO3CR\Domain\Model\Workspace;
use TYPO3\TYPO3CR\Domain\Repository\NodeDataRepository;
use TYPO3\TYPO3CR\Domain\Repository\WorkspaceRepository;
use TYPO3\TYPO3CR\TypeConverter\NodeConverter;

/**
Expand All @@ -23,40 +30,40 @@ class WorkspaceController extends AbstractServiceController
/**
* @var string
*/
protected $defaultViewObjectName = 'TYPO3\Neos\Service\View\NodeView';
protected $defaultViewObjectName = NodeView::class;

/**
* @var \TYPO3\Neos\Service\View\NodeView
* @var NodeView
*/
protected $view;

/**
* @Flow\Inject
* @var \TYPO3\TYPO3CR\Domain\Repository\NodeDataRepository
* @var NodeDataRepository
*/
protected $nodeDataRepository;

/**
* @Flow\Inject
* @var \TYPO3\Neos\Service\PublishingService
* @var PublishingService
*/
protected $publishingService;

/**
* @Flow\Inject
* @var \TYPO3\TYPO3CR\Domain\Repository\WorkspaceRepository
* @var WorkspaceRepository
*/
protected $workspaceRepository;

/**
* @Flow\Inject
* @var \TYPO3\Flow\Property\PropertyMapper
* @var PropertyMapper
*/
protected $propertyMapper;

/**
* @Flow\Inject
* @var \TYPO3\Flow\Property\PropertyMappingConfigurationBuilder
* @var PropertyMappingConfigurationBuilder
*/
protected $propertyMappingConfigurationBuilder;

Expand All @@ -70,7 +77,7 @@ protected function initializeAction()
->arguments
->getArgument('node')
->getPropertyMappingConfiguration()
->setTypeConverterOption('TYPO3\TYPO3CR\TypeConverter\NodeConverter', NodeConverter::REMOVED_CONTENT_SHOWN, true);
->setTypeConverterOption(NodeConverter::class, NodeConverter::REMOVED_CONTENT_SHOWN, true);
}

if ($this->arguments->hasArgument('nodes')) {
Expand All @@ -79,7 +86,7 @@ protected function initializeAction()
->getArgument('nodes')
->getPropertyMappingConfiguration()
->forProperty('*')
->setTypeConverterOption('TYPO3\TYPO3CR\TypeConverter\NodeConverter', NodeConverter::REMOVED_CONTENT_SHOWN, true);
->setTypeConverterOption(NodeConverter::class, NodeConverter::REMOVED_CONTENT_SHOWN, true);
}
}

Expand Down Expand Up @@ -164,7 +171,7 @@ public function publishAllAction($sourceWorkspaceName, $targetWorkspaceName)
/**
* Get every unpublished node in the workspace with the given workspace name
*
* @param \TYPO3\TYPO3CR\Domain\Model\Workspace $workspace
* @param Workspace $workspace
* @return void
*/
public function getWorkspaceWideUnpublishedNodesAction($workspace)
Expand All @@ -175,7 +182,7 @@ public function getWorkspaceWideUnpublishedNodesAction($workspace)
/**
* Discard everything in the workspace with the given workspace name
*
* @param \TYPO3\TYPO3CR\Domain\Model\Workspace $workspace
* @param Workspace $workspace
* @return void
*/
public function discardAllAction($workspace)
Expand Down
Expand Up @@ -12,6 +12,7 @@
*/

use TYPO3\Flow\Mvc\Controller\ControllerContext;
use TYPO3\Neos\Exception;

/**
* Data source interface for getting data.
Expand All @@ -37,12 +38,12 @@ abstract class AbstractDataSource implements DataSourceInterface
/**
* @return string the short name of the operation
* @api
* @throws \TYPO3\Neos\Exception
* @throws Exception
*/
public static function getIdentifier()
{
if (!is_string(static::$identifier)) {
throw new \TYPO3\Neos\Exception('Identifier in class ' . __CLASS__ . ' is empty.', 1414090236);
throw new Exception('Identifier in class ' . __CLASS__ . ' is empty.', 1414090236);
}

return static::$identifier;
Expand Down
2 changes: 1 addition & 1 deletion TYPO3.Neos/Classes/TYPO3/Neos/Service/LinkingService.php
Expand Up @@ -237,7 +237,7 @@ public function createNodeUri(ControllerContext $controllerContext, $node = null
}
preg_match(NodeInterface::MATCH_PATTERN_CONTEXTPATH, $nodeString, $matches);
if (isset($matches['WorkspaceName']) && $matches['WorkspaceName'] !== '') {
$node = $this->propertyMapper->convert($nodeString, 'TYPO3\TYPO3CR\Domain\Model\NodeInterface');
$node = $this->propertyMapper->convert($nodeString, NodeInterface::class);
} else {
if ($baseNode === null) {
throw new NeosException('The baseNode argument is required for linking to nodes with a relative path.', 1407879905);
Expand Down
2 changes: 1 addition & 1 deletion TYPO3.Neos/Classes/TYPO3/Neos/Service/PluginService.php
Expand Up @@ -210,7 +210,7 @@ public function getPluginViewNodeByMasterPlugin(NodeInterface $node, $viewName)
/** @var $context ContentContext */
$context = $node->getContext();
foreach ($this->getNodes(['TYPO3.Neos:PluginView'], $context) as $pluginViewNode) {
/** @var \TYPO3\TYPO3CR\Domain\Model\NodeInterface $pluginViewNode */
/** @var NodeInterface $pluginViewNode */
if ($pluginViewNode->isRemoved()) {
continue;
}
Expand Down
Expand Up @@ -11,6 +11,7 @@
* source code.
*/

use Behat\Transliterator\Transliterator;
use TYPO3\Flow\Annotations as Flow;
use TYPO3\Flow\I18n\Service as LocalizationService;

Expand Down Expand Up @@ -50,8 +51,8 @@ public function transliterate($text, $language = null)
}

// Transliterate (transform 北京 to 'Bei Jing')
if (preg_match('/[\x80-\xff]/', $text) && \Behat\Transliterator\Transliterator::validUtf8($text)) {
$text = \Behat\Transliterator\Transliterator::utf8ToAscii($text);
if (preg_match('/[\x80-\xff]/', $text) && Transliterator::validUtf8($text)) {
$text = Transliterator::utf8ToAscii($text);
}

return $text;
Expand Down
5 changes: 3 additions & 2 deletions TYPO3.Neos/Classes/TYPO3/Neos/Service/VieSchemaBuilder.php
Expand Up @@ -13,6 +13,7 @@

use TYPO3\Flow\Annotations as Flow;
use TYPO3\TYPO3CR\Domain\Model\NodeType;
use TYPO3\TYPO3CR\Domain\Service\NodeTypeManager;

/**
* Generate a schema in JSON format for the VIE dataTypes validation, necessary
Expand All @@ -25,7 +26,7 @@
class VieSchemaBuilder
{
/**
* @var \TYPO3\TYPO3CR\Domain\Service\NodeTypeManager
* @var NodeTypeManager
* @Flow\Inject
*/
protected $nodeTypeManager;
Expand Down Expand Up @@ -106,7 +107,7 @@ public function generateVieSchema()

/**
* @param string $nodeTypeName
* @param \TYPO3\TYPO3CR\Domain\Model\NodeType $nodeType
* @param NodeType $nodeType
* @return void
*/
protected function readNodeTypeConfiguration($nodeTypeName, NodeType $nodeType)
Expand Down
3 changes: 2 additions & 1 deletion TYPO3.Neos/Classes/TYPO3/Neos/Service/View/NodeView.php
Expand Up @@ -14,6 +14,7 @@
use TYPO3\Flow\Annotations as Flow;
use TYPO3\Eel\FlowQuery\FlowQuery;
use TYPO3\Flow\Log\SystemLoggerInterface;
use TYPO3\Flow\Mvc\View\JsonView;
use TYPO3\Flow\Security\Authorization\PrivilegeManagerInterface;
use TYPO3\Neos\Security\Authorization\Privilege\NodeTreePrivilege;
use TYPO3\TYPO3CR\Domain\Model\NodeInterface;
Expand All @@ -28,7 +29,7 @@
*
* @Flow\Scope("prototype")
*/
class NodeView extends \TYPO3\Flow\Mvc\View\JsonView
class NodeView extends JsonView
{
/**
* @var integer
Expand Down
6 changes: 4 additions & 2 deletions TYPO3.Neos/Classes/TYPO3/Neos/Service/XliffService.php
Expand Up @@ -13,6 +13,8 @@

use TYPO3\Flow\Annotations as Flow;
use TYPO3\Flow\Cache\Frontend\VariableFrontend;
use TYPO3\Flow\Error\Result;
use TYPO3\Flow\I18n\Exception;
use TYPO3\Flow\I18n\Xliff\XliffParser;
use TYPO3\Flow\Package\PackageManagerInterface;
use TYPO3\Flow\Utility\Arrays;
Expand Down Expand Up @@ -76,8 +78,8 @@ class XliffService
* The json will be cached.
*
* @param Locale $locale The locale
* @return \TYPO3\Flow\Error\Result
* @throws \TYPO3\Flow\I18n\Exception
* @return Result
* @throws Exception
*/
public function getCachedJson(Locale $locale)
{
Expand Down