当前位置: 首页>>代码示例>>PHP>>正文


PHP ObjectManagerInterface::getScope方法代码示例

本文整理汇总了PHP中TYPO3\Flow\Object\ObjectManagerInterface::getScope方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectManagerInterface::getScope方法的具体用法?PHP ObjectManagerInterface::getScope怎么用?PHP ObjectManagerInterface::getScope使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TYPO3\Flow\Object\ObjectManagerInterface的用法示例。


在下文中一共展示了ObjectManagerInterface::getScope方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: synchronizeCommand

 /**
  * Synchronize designs from Flow declarations to CouchDB documents
  *
  * @return void
  * @author Christopher Hlubek <hlubek@networkteam.com>
  */
 public function synchronizeCommand()
 {
     $designDocumentClassNames = $this->reflectionService->getAllSubClassNamesForClass('TYPO3\\CouchDB\\DesignDocument');
     foreach ($designDocumentClassNames as $objectName) {
         if ($this->objectManager->getScope($objectName) === \TYPO3\Flow\Object\Configuration\Configuration::SCOPE_SINGLETON) {
             $designDocument = $this->objectManager->get($objectName);
             $designDocument->synchronize();
             $this->outputLine($objectName . ' synchronized.');
         } else {
             $this->outputLine($objectName . ' skipped.');
         }
     }
 }
开发者ID:radmiraal,项目名称:TYPO3.CouchDB,代码行数:19,代码来源:DesignCommandController.php

示例2: resume

 /**
  * Resumes an existing session, if any.
  *
  * @return integer If a session was resumed, the inactivity of since the last request is returned
  * @api
  */
 public function resume()
 {
     if ($this->started === false && $this->canBeResumed()) {
         $this->sessionIdentifier = $this->sessionCookie->getValue();
         $this->response->setCookie($this->sessionCookie);
         $this->started = true;
         $sessionObjects = $this->storageCache->get($this->storageIdentifier . md5('TYPO3_Flow_Object_ObjectManager'));
         if (is_array($sessionObjects)) {
             foreach ($sessionObjects as $object) {
                 if ($object instanceof ProxyInterface) {
                     $objectName = $this->objectManager->getObjectNameByClassName(get_class($object));
                     if ($this->objectManager->getScope($objectName) === ObjectConfiguration::SCOPE_SESSION) {
                         $this->objectManager->setInstance($objectName, $object);
                         $this->objectManager->get(\TYPO3\Flow\Session\Aspect\LazyLoadingAspect::class)->registerSessionInstance($objectName, $object);
                     }
                 }
             }
         } else {
             // Fallback for some malformed session data, if it is no array but something else.
             // In this case, we reset all session objects (graceful degradation).
             $this->storageCache->set($this->storageIdentifier . md5('TYPO3_Flow_Object_ObjectManager'), array(), array($this->storageIdentifier), 0);
         }
         $lastActivitySecondsAgo = $this->now - $this->lastActivityTimestamp;
         $this->lastActivityTimestamp = $this->now;
         return $lastActivitySecondsAgo;
     }
 }
开发者ID:cerlestes,项目名称:flow-development-collection,代码行数:33,代码来源:Session.php

示例3: matches

 /**
  * Checks if the specified class and method matches against the filter
  *
  * @param string $className Name of the class to check against
  * @param string $methodName Name of the method to check against
  * @param string $methodDeclaringClassName Name of the class the method was originally declared in
  * @param mixed $pointcutQueryIdentifier Some identifier for this query - must at least differ from a previous identifier. Used for circular reference detection.
  * @return boolean TRUE if the class / method match, otherwise FALSE
  */
 public function matches($className, $methodName, $methodDeclaringClassName, $pointcutQueryIdentifier)
 {
     if ($methodName === null) {
         return false;
     }
     $objectName = $this->objectManager->getObjectNameByClassName($className);
     if (empty($objectName)) {
         return false;
     }
     if ($this->objectManager->getScope($objectName) !== ObjectConfiguration::SCOPE_SESSION) {
         return false;
     }
     if (preg_match('/^__wakeup|__construct|__destruct|__sleep|__serialize|__unserialize|__clone|shutdownObject|initializeObject|inject.*$/', $methodName) !== 0) {
         return false;
     }
     return true;
 }
开发者ID:mkeitsch,项目名称:flow-development-collection,代码行数:26,代码来源:SessionObjectMethodsPointcutFilter.php

示例4: buildBaseValidatorConjunction

 /**
  * Builds a base validator conjunction for the given data type.
  *
  * The base validation rules are those which were declared directly in a class (typically
  * a model) through some validate annotations on properties.
  *
  * If a property holds a class for which a base validator exists, that property will be
  * checked as well, regardless of a validate annotation
  *
  * Additionally, if a custom validator was defined for the class in question, it will be added
  * to the end of the conjunction. A custom validator is found if it follows the naming convention
  * "Replace '\Model\' by '\Validator\' and append 'Validator'".
  *
  * Example: $targetClassName is Neos\Foo\Domain\Model\Quux, then the validator will be found if it has the
  * name Neos\Foo\Domain\Validator\QuuxValidator
  *
  * @param string $indexKey The key to use as index in $this->baseValidatorConjunctions; calculated from target class name and validation groups
  * @param string $targetClassName The data type to build the validation conjunction for. Needs to be the fully qualified class name.
  * @param array $validationGroups The validation groups to build the validator for
  * @return void
  * @throws Exception\NoSuchValidatorException
  * @throws \InvalidArgumentException
  */
 protected function buildBaseValidatorConjunction($indexKey, $targetClassName, array $validationGroups)
 {
     $conjunctionValidator = new ConjunctionValidator();
     $this->baseValidatorConjunctions[$indexKey] = $conjunctionValidator;
     if (!TypeHandling::isSimpleType($targetClassName) && class_exists($targetClassName)) {
         // Model based validator
         $classSchema = $this->reflectionService->getClassSchema($targetClassName);
         if ($classSchema !== null && $classSchema->isAggregateRoot()) {
             $objectValidator = new AggregateBoundaryValidator(array());
         } else {
             $objectValidator = new GenericObjectValidator([]);
         }
         $conjunctionValidator->addValidator($objectValidator);
         foreach ($this->reflectionService->getClassPropertyNames($targetClassName) as $classPropertyName) {
             $classPropertyTagsValues = $this->reflectionService->getPropertyTagsValues($targetClassName, $classPropertyName);
             if (!isset($classPropertyTagsValues['var'])) {
                 throw new \InvalidArgumentException(sprintf('There is no @var annotation for property "%s" in class "%s".', $classPropertyName, $targetClassName), 1363778104);
             }
             try {
                 $parsedType = TypeHandling::parseType(trim(implode('', $classPropertyTagsValues['var']), ' \\'));
             } catch (InvalidTypeException $exception) {
                 throw new \InvalidArgumentException(sprintf(' @var annotation of ' . $exception->getMessage(), 'class "' . $targetClassName . '", property "' . $classPropertyName . '"'), 1315564744, $exception);
             }
             if ($this->reflectionService->isPropertyAnnotatedWith($targetClassName, $classPropertyName, Flow\IgnoreValidation::class)) {
                 continue;
             }
             $propertyTargetClassName = $parsedType['type'];
             if (TypeHandling::isCollectionType($propertyTargetClassName) === true) {
                 $collectionValidator = $this->createValidator(Validator\CollectionValidator::class, ['elementType' => $parsedType['elementType'], 'validationGroups' => $validationGroups]);
                 $objectValidator->addPropertyValidator($classPropertyName, $collectionValidator);
             } elseif (!TypeHandling::isSimpleType($propertyTargetClassName) && $this->objectManager->isRegistered($propertyTargetClassName) && $this->objectManager->getScope($propertyTargetClassName) === Configuration::SCOPE_PROTOTYPE) {
                 $validatorForProperty = $this->getBaseValidatorConjunction($propertyTargetClassName, $validationGroups);
                 if (count($validatorForProperty) > 0) {
                     $objectValidator->addPropertyValidator($classPropertyName, $validatorForProperty);
                 }
             }
             $validateAnnotations = $this->reflectionService->getPropertyAnnotations($targetClassName, $classPropertyName, Flow\Validate::class);
             foreach ($validateAnnotations as $validateAnnotation) {
                 if (count(array_intersect($validateAnnotation->validationGroups, $validationGroups)) === 0) {
                     // In this case, the validation groups for the property do not match current validation context
                     continue;
                 }
                 $newValidator = $this->createValidator($validateAnnotation->type, $validateAnnotation->options);
                 if ($newValidator === null) {
                     throw new Exception\NoSuchValidatorException('Invalid validate annotation in ' . $targetClassName . '::' . $classPropertyName . ': Could not resolve class name for  validator "' . $validateAnnotation->type . '".', 1241098027);
                 }
                 $objectValidator->addPropertyValidator($classPropertyName, $newValidator);
             }
         }
         if (count($objectValidator->getPropertyValidators()) === 0) {
             $conjunctionValidator->removeValidator($objectValidator);
         }
     }
     $this->addCustomValidators($targetClassName, $conjunctionValidator);
 }
开发者ID:RafaelKa,项目名称:flow-development-collection,代码行数:78,代码来源:ValidatorResolver.php

示例5: transformObject

 /**
  * Traverses the given object structure in order to transform it into an
  * array structure.
  *
  * @param object $object Object to traverse
  * @param array $configuration Configuration for transforming the given object
  * @param boolean $onlyIdentifier
  * @return array Object structure as an array
  * @todo implement sideloading
  */
 protected function transformObject($object, array $configuration, $onlyIdentifier = TRUE)
 {
     if ($object instanceof \DateTime) {
         return $object->format('Y-m-d\\TH:i:s');
     } elseif ($onlyIdentifier === TRUE) {
         $objectIdentifier = $this->persistenceManager->getIdentifierByObject($object);
         if ($objectIdentifier === NULL && method_exists($object, 'getId')) {
             $objectIdentifier = $object->getId();
         }
         return $objectIdentifier;
     } else {
         $transformedObject = array();
         if ($this->excludeIdentifier === FALSE) {
             $objectIdentifier = $this->persistenceManager->getIdentifierByObject($object);
             $transformedObject['id'] = $objectIdentifier;
         }
         $propertyNames = ObjectAccess::getGettablePropertyNames($object);
         foreach ($propertyNames as $propertyName) {
             if (substr($propertyName, 0, 1) !== '_') {
                 if (isset($configuration['_only']) && is_array($configuration['_only']) && !in_array($propertyName, $configuration['_only'])) {
                     continue;
                 }
                 if ($this->propertyIsExcluded($propertyName, $configuration)) {
                     continue;
                 }
                 $propertyValue = ObjectAccess::getProperty($object, $propertyName);
                 $objectName = $this->objectManager->getObjectNameByClassName($this->reflectionService->getClassNameByObject($object));
                 if (!$this->reflectionService->isPropertyAnnotatedWith($objectName, $propertyName, 'TYPO3\\Flow\\Annotations\\Transient')) {
                     if (is_array($propertyValue) || $propertyValue instanceof \ArrayAccess) {
                         $transformedObject[EmberDataUtility::uncamelize($propertyName)] = $this->transformValue($propertyValue, array());
                     } elseif ($propertyValue instanceof \DateTime) {
                         $transformedObject[EmberDataUtility::uncamelize($propertyName)] = $propertyValue->format('Y-m-d\\TH:i:s');
                     } elseif (is_object($propertyValue)) {
                         $objectName = $this->objectManager->getObjectNameByClassName($this->reflectionService->getClassNameByObject($object));
                         if ($this->objectManager->getScope($objectName) !== \TYPO3\Flow\Object\Configuration\Configuration::SCOPE_SINGLETON) {
                             $transformedObject[EmberDataUtility::uncamelize($propertyName) . '_id'] = $this->persistenceManager->getIdentifierByObject($propertyValue);
                             if (isset($configuration['sideloadedAssociations']) && in_array($propertyName, $configuration['sideloadedAssociations'])) {
                                 // sideload this propertyvalue
                             }
                         }
                     } else {
                         $transformedObject[EmberDataUtility::uncamelize($propertyName)] = $propertyValue;
                     }
                 }
             }
         }
         return $transformedObject;
     }
 }
开发者ID:putheakhem,项目名称:Radmiraal.Emberjs,代码行数:59,代码来源:RestView.php

示例6: buildObject

 /**
  * Builds a new instance of $objectType with the given $possibleConstructorArgumentValues.
  * If constructor argument values are missing from the given array the method looks for a
  * default value in the constructor signature.
  *
  * Furthermore, the constructor arguments are removed from $possibleConstructorArgumentValues
  *
  * @param array &$possibleConstructorArgumentValues
  * @param string $objectType
  * @return object The created instance
  * @throws InvalidTargetException if a required constructor argument is missing
  */
 protected function buildObject(array &$possibleConstructorArgumentValues, $objectType)
 {
     $constructorArguments = [];
     $className = $this->objectManager->getClassNameByObjectName($objectType);
     $constructorSignature = $this->getConstructorArgumentsForClass($className);
     if (count($constructorSignature)) {
         foreach ($constructorSignature as $constructorArgumentName => $constructorArgumentReflection) {
             if (array_key_exists($constructorArgumentName, $possibleConstructorArgumentValues)) {
                 $constructorArguments[] = $possibleConstructorArgumentValues[$constructorArgumentName];
                 unset($possibleConstructorArgumentValues[$constructorArgumentName]);
             } elseif ($constructorArgumentReflection['optional'] === true) {
                 $constructorArguments[] = $constructorArgumentReflection['defaultValue'];
             } elseif ($this->objectManager->isRegistered($constructorArgumentReflection['type']) && $this->objectManager->getScope($constructorArgumentReflection['type']) === Configuration::SCOPE_SINGLETON) {
                 $constructorArguments[] = $this->objectManager->get($constructorArgumentReflection['type']);
             } else {
                 throw new InvalidTargetException('Missing constructor argument "' . $constructorArgumentName . '" for object of type "' . $objectType . '".', 1268734872);
             }
         }
         $classReflection = new \ReflectionClass($className);
         return $classReflection->newInstanceArgs($constructorArguments);
     } else {
         return new $className();
     }
 }
开发者ID:mkeitsch,项目名称:flow-development-collection,代码行数:36,代码来源:ObjectConverter.php

示例7: renderObjectDump

 /**
  * Renders a dump of the given object
  *
  * @param object $object
  * @param integer $level
  * @param boolean $renderProperties
  * @param boolean $plaintext
  * @param boolean $ansiColors
  * @return string
  */
 protected static function renderObjectDump($object, $level, $renderProperties = TRUE, $plaintext = FALSE, $ansiColors = FALSE)
 {
     $dump = '';
     $scope = '';
     $additionalAttributes = '';
     if ($object instanceof \Doctrine\Common\Collections\Collection) {
         return self::renderArrayDump(\Doctrine\Common\Util\Debug::export($object, 3), $level, $plaintext, $ansiColors);
     }
     // Objects returned from Doctrine's Debug::export function are stdClass with special properties:
     try {
         $objectIdentifier = ObjectAccess::getProperty($object, 'Persistence_Object_Identifier', TRUE);
     } catch (\TYPO3\Flow\Reflection\Exception\PropertyNotAccessibleException $exception) {
         $objectIdentifier = spl_object_hash($object);
     }
     $className = $object instanceof \stdClass && isset($object->__CLASS__) ? $object->__CLASS__ : get_class($object);
     if (isset(self::$renderedObjects[$objectIdentifier]) || preg_match(self::getIgnoredClassesRegex(), $className) !== 0) {
         $renderProperties = FALSE;
     }
     self::$renderedObjects[$objectIdentifier] = TRUE;
     if (self::$objectManager !== NULL) {
         $objectName = self::$objectManager->getObjectNameByClassName(get_class($object));
         if ($objectName !== FALSE) {
             switch (self::$objectManager->getScope($objectName)) {
                 case \TYPO3\Flow\Object\Configuration\Configuration::SCOPE_PROTOTYPE:
                     $scope = 'prototype';
                     break;
                 case \TYPO3\Flow\Object\Configuration\Configuration::SCOPE_SINGLETON:
                     $scope = 'singleton';
                     break;
                 case \TYPO3\Flow\Object\Configuration\Configuration::SCOPE_SESSION:
                     $scope = 'session';
                     break;
             }
         } else {
             $additionalAttributes .= ' debug-unregistered';
         }
     }
     if ($renderProperties === TRUE && !$plaintext) {
         if ($scope === '') {
             $scope = 'prototype';
         }
         $scope .= '<a id="o' . $objectIdentifier . '"></a>';
     }
     if ($plaintext) {
         $dump .= $className;
         $dump .= $scope !== '' ? ' ' . self::ansiEscapeWrap($scope, '44;37', $ansiColors) : '';
     } else {
         $dump .= '<span class="debug-object' . $additionalAttributes . '" title="' . $objectIdentifier . '">' . $className . '</span>';
         $dump .= $scope !== '' ? '<span class="debug-scope">' . $scope . '</span>' : '';
     }
     if (property_exists($object, 'Persistence_Object_Identifier')) {
         $persistenceIdentifier = $objectIdentifier;
         $persistenceType = 'persistable';
     } elseif ($object instanceof \Closure) {
         $persistenceIdentifier = 'n/a';
         $persistenceType = 'closure';
     } else {
         $persistenceIdentifier = 'unknown';
         $persistenceType = 'object';
     }
     if ($plaintext) {
         $dump .= ' ' . self::ansiEscapeWrap($persistenceType, '42;37', $ansiColors);
     } else {
         $dump .= '<span class="debug-ptype" title="' . $persistenceIdentifier . '">' . $persistenceType . '</span>';
     }
     if ($object instanceof \TYPO3\Flow\Object\Proxy\ProxyInterface || property_exists($object, '__IS_PROXY__') && $object->__IS_PROXY__ === TRUE) {
         if ($plaintext) {
             $dump .= ' ' . self::ansiEscapeWrap('proxy', '41;37', $ansiColors);
         } else {
             $dump .= '<span class="debug-proxy" title="' . $className . '">proxy</span>';
         }
     }
     if ($renderProperties === TRUE) {
         if ($object instanceof \SplObjectStorage) {
             $dump .= ' (' . (count($object) ?: 'empty') . ')';
             foreach ($object as $value) {
                 $dump .= chr(10);
                 $dump .= str_repeat(' ', $level);
                 $dump .= self::renderObjectDump($value, 0, FALSE, $plaintext, $ansiColors);
             }
         } else {
             $classReflection = new \ReflectionClass($className);
             $properties = $classReflection->getProperties();
             foreach ($properties as $property) {
                 if (preg_match(self::$blacklistedPropertyNames, $property->getName())) {
                     continue;
                 }
                 $dump .= chr(10);
                 $dump .= str_repeat(' ', $level) . ($plaintext ? '' : '<span class="debug-property">') . self::ansiEscapeWrap($property->getName(), '36', $ansiColors) . ($plaintext ? '' : '</span>') . ' => ';
                 $property->setAccessible(TRUE);
//.........这里部分代码省略.........
开发者ID:sengkimlong,项目名称:Flow3-Authentification,代码行数:101,代码来源:Debugger.php

示例8: serializeObjectAsPropertyArray

 /**
  * Serializes an object as property array.
  *
  * @param object $object The object to store in the registry
  * @param boolean $isTopLevelItem Internal flag for managing the recursion
  * @return array The property array
  */
 public function serializeObjectAsPropertyArray($object, $isTopLevelItem = true)
 {
     if ($isTopLevelItem) {
         $this->objectReferences = new \SplObjectStorage();
     }
     $this->objectReferences->attach($object);
     $className = get_class($object);
     $propertyArray = array();
     foreach ($this->reflectionService->getClassPropertyNames($className) as $propertyName) {
         if ($this->reflectionService->isPropertyTaggedWith($className, $propertyName, 'transient')) {
             continue;
         }
         $propertyReflection = new \TYPO3\Flow\Reflection\PropertyReflection($className, $propertyName);
         $propertyValue = $propertyReflection->getValue($object);
         if (is_object($propertyValue) && $propertyValue instanceof \TYPO3\Flow\Object\DependencyInjection\DependencyProxy) {
             continue;
         }
         if (is_object($propertyValue) && isset($this->objectReferences[$propertyValue])) {
             $propertyArray[$propertyName][self::TYPE] = 'object';
             $propertyArray[$propertyName][self::VALUE] = \spl_object_hash($propertyValue);
             continue;
         }
         $propertyClassName = is_object($propertyValue) ? get_class($propertyValue) : '';
         if ($propertyClassName === 'SplObjectStorage') {
             $propertyArray[$propertyName][self::TYPE] = 'SplObjectStorage';
             $propertyArray[$propertyName][self::VALUE] = array();
             foreach ($propertyValue as $storedObject) {
                 $propertyArray[$propertyName][self::VALUE][] = spl_object_hash($storedObject);
                 $this->serializeObjectAsPropertyArray($storedObject, false);
             }
         } elseif (is_object($propertyValue) && $propertyValue instanceof \Doctrine\Common\Collections\Collection) {
             $propertyArray[$propertyName][self::TYPE] = 'Collection';
             $propertyArray[$propertyName][self::CLASSNAME] = get_class($propertyValue);
             foreach ($propertyValue as $storedObject) {
                 $propertyArray[$propertyName][self::VALUE][] = spl_object_hash($storedObject);
                 $this->serializeObjectAsPropertyArray($storedObject, false);
             }
         } elseif (is_object($propertyValue) && $propertyValue instanceof \ArrayObject) {
             $propertyArray[$propertyName][self::TYPE] = 'ArrayObject';
             $propertyArray[$propertyName][self::VALUE] = $this->buildStorageArrayForArrayProperty($propertyValue->getArrayCopy());
         } elseif (is_object($propertyValue) && $this->persistenceManager->isNewObject($propertyValue) === false && ($this->reflectionService->isClassAnnotatedWith($propertyClassName, \TYPO3\Flow\Annotations\Entity::class) || $this->reflectionService->isClassAnnotatedWith($propertyClassName, \TYPO3\Flow\Annotations\ValueObject::class) || $this->reflectionService->isClassAnnotatedWith($propertyClassName, 'Doctrine\\ORM\\Mapping\\Entity'))) {
             $propertyArray[$propertyName][self::TYPE] = 'persistenceObject';
             $propertyArray[$propertyName][self::VALUE] = get_class($propertyValue) . ':' . $this->persistenceManager->getIdentifierByObject($propertyValue);
         } elseif (is_object($propertyValue)) {
             $propertyObjectName = $this->objectManager->getObjectNameByClassName($propertyClassName);
             if ($this->objectManager->getScope($propertyObjectName) === \TYPO3\Flow\Object\Configuration\Configuration::SCOPE_SINGLETON) {
                 continue;
             }
             $propertyArray[$propertyName][self::TYPE] = 'object';
             $propertyArray[$propertyName][self::VALUE] = spl_object_hash($propertyValue);
             $this->serializeObjectAsPropertyArray($propertyValue, false);
         } elseif (is_array($propertyValue)) {
             $propertyArray[$propertyName][self::TYPE] = 'array';
             $propertyArray[$propertyName][self::VALUE] = $this->buildStorageArrayForArrayProperty($propertyValue);
         } else {
             $propertyArray[$propertyName][self::TYPE] = 'simple';
             $propertyArray[$propertyName][self::VALUE] = $propertyValue;
         }
     }
     $this->objectsAsArray[spl_object_hash($object)] = array(self::CLASSNAME => $className, self::PROPERTIES => $propertyArray);
     if ($isTopLevelItem) {
         return $this->objectsAsArray;
     }
 }
开发者ID:robertlemke,项目名称:flow-development-collection,代码行数:71,代码来源:ObjectSerializer.php

示例9: isObjectIgnored

 /**
  * Returns TRUE if the object should be ignored
  *
  * @param string $objectName
  * @return boolean
  */
 protected function isObjectIgnored($objectName)
 {
     return $this->objectManager->getScope($objectName) === Configuration::SCOPE_SINGLETON;
 }
开发者ID:putheakhem,项目名称:Radmiraal.Emberjs,代码行数:10,代码来源:JsonApiSerializer.php


注:本文中的TYPO3\Flow\Object\ObjectManagerInterface::getScope方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。