protected function createClassBody($class, $type) { if (!class_exists($class)) { throw new \InvalidArgumentException(sprintf('Class %s does not exist', $class)); } if (substr($class, -4) !== 'Base') { throw new \InvalidArgumentException('The class must end in `Base`'); } $refClass = new \ReflectionClass($class); $namespace = $refClass->getNamespaceName(); $baseClassName = $namespace ? substr($refClass->getName(), strlen($namespace) + 1) : $refClass->getName(); $destinationClassName = substr($baseClassName, 0, -4); $layerableMethods = array(); $fileLines = file($refClass->getFileName()); foreach ($refClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) { if (strpos($method->getDocComment(), '@Stratum\\Layerable')) { $methodBody = implode(PHP_EOL, array_slice($fileLines, $method->getStartLine() - 1, $method->getEndLine() - $method->getStartLine() + 1)); $layerableMethods[] = array('head' => substr($methodBody, 0, strpos($methodBody, '{')), 'name' => $method->getName(), 'arguments' => implode(', ', array_map(function ($parameter) { return '$' . $parameter->getName(); }, $method->getParameters()))); } } if (!in_array($type, array('class', 'layer', 'wrapper'))) { throw new \InvalidArgumentException('Invalid type of class. Allowed values are `class`, `layer` and `wrapper`.'); } ob_start(); include_once __DIR__ . '/../templates/' . $type . '.php'; $output = ob_get_clean(); return $output; }
/** * @param \ReflectionClass|string * @return self */ public static function from($from) { $from = new \ReflectionClass($from instanceof \ReflectionClass ? $from->getName() : $from); if (PHP_VERSION_ID >= 70000 && $from->isAnonymous()) { $class = new static('anonymous'); } else { $class = new static($from->getShortName(), new PhpNamespace($from->getNamespaceName())); } $class->type = $from->isInterface() ? 'interface' : (PHP_VERSION_ID >= 50400 && $from->isTrait() ? 'trait' : 'class'); $class->final = $from->isFinal() && $class->type === 'class'; $class->abstract = $from->isAbstract() && $class->type === 'class'; $class->implements = $from->getInterfaceNames(); $class->documents = $from->getDocComment() ? array(preg_replace('#^\\s*\\* ?#m', '', trim($from->getDocComment(), "/* \r\n\t"))) : array(); if ($from->getParentClass()) { $class->extends = $from->getParentClass()->getName(); $class->implements = array_diff($class->implements, $from->getParentClass()->getInterfaceNames()); } foreach ($from->getProperties() as $prop) { if ($prop->getDeclaringClass()->getName() === $from->getName()) { $class->properties[$prop->getName()] = Property::from($prop); } } foreach ($from->getMethods() as $method) { if ($method->getDeclaringClass()->getName() === $from->getName()) { $class->methods[$method->getName()] = Method::from($method)->setNamespace($class->namespace); } } return $class; }
/** * Helper method to get all REST services. * * @todo Build a cache for this! * * @return array */ protected function getRestServices() { /** * Lambda function to get all service classes that exists in application. * * @param string $file * * @return null|\stdClass */ $iterator = function ($file) { // Specify service class name with namespace $className = '\\App\\Services\\' . str_replace('.php', '', basename($file)); // Get reflection about controller class $reflectionClass = new \ReflectionClass($className); if (!$reflectionClass->isAbstract() && $reflectionClass->implementsInterface('\\App\\Services\\Interfaces\\Rest')) { $bits = explode('\\', $reflectionClass->getName()); // Create output $output = new \stdClass(); $output->class = $reflectionClass->getName(); $output->name = 'service.' . end($bits); return $output; } return null; }; return array_filter(array_map($iterator, glob($this->app->getRootDir() . 'src/App/Services/*.php'))); }
/** * * @param InjectorInterface $injector * @return mixed */ protected function getInstance(InjectorInterface $injector) { $name = $this->aliasClassReflection->getName(); $nameValueMap = $this->getNameValueMap(); $definitionArray = $this->getDefinitionArray(); return $injector->create($name, $nameValueMap, $definitionArray); }
public function getInjectionProperties(\ReflectionClass $class) { $injections = array(); $properties = $class->getProperties(); /* @var $prop \ReflectionProperty */ foreach ($properties as $prop) { preg_match("/@Inject(.*?)[\\*\\@]/si", $prop->getDocComment(), $m); if (count($m) > 0) { $dep = trim(str_replace(array('(', ')', '"'), '', $m[1])); if (strpos($dep, ',') !== false) { throw new AnnotationException("Commatas are not allowed for class property inject annotations! " . $class->getName() . '#' . $prop->name); } if (strlen($dep) > 0) { $injections[$prop->getName()] = array('class' => trim($dep)); continue; } preg_match("/@var\\s(.*?)[\\*\\@\\s]/si", $prop->getDocComment(), $ma); if (count($ma) > 0) { $injections[$prop->getName()] = array('class' => trim($ma[1])); continue; } throw new AnnotationException("If no @var annotation is provided, you have to specify the value or class for the property with the inject annotation! " . $class->getName() . '#' . $prop->name); } } return $injections; }
/** * {@inheritdoc} */ public function loadMetadataFromFile(\ReflectionClass $class, $path) { $classMetadata = new ClassMetadata($class->getName()); $use = libxml_use_internal_errors(true); $dom = new \DOMDocument('1.0'); $dom->load($path); if (!$dom->schemaValidate(__DIR__ . '/../../../schema/mapping.xsd')) { $message = array_reduce(libxml_get_errors(), function ($foo, $error) { return $error->message; }); throw new \InvalidArgumentException(sprintf('Could not validate XML mapping at "%s": %s', $path, $message)); } libxml_use_internal_errors($use); $xpath = new \DOMXpath($dom); $xpath->registerNamespace('psict', self::XML_NAMESPACE); foreach ($xpath->query('//psict:class') as $classEl) { $classAttr = $classEl->getAttribute('name'); if ($classAttr !== $class->getName()) { throw new \InvalidArgumentException(sprintf('Expected class name to be "%s" but it is mapped as "%s"', $class->getName(), $classAttr)); } foreach ($xpath->query('./psict:field', $classEl) as $fieldEl) { $shared = $this->extractOptionSet($xpath, $fieldEl, 'shared-options'); $form = $this->extractOptionSet($xpath, $fieldEl, 'form-options'); $view = $this->extractOptionSet($xpath, $fieldEl, 'view-options'); $storage = $this->extractOptionSet($xpath, $fieldEl, 'storage-options'); $propertyMetadata = new PropertyMetadata($class->getName(), $fieldEl->getAttribute('name'), $fieldEl->getAttribute('type'), $fieldEl->getAttribute('role'), $fieldEl->getAttribute('group'), ['shared' => $shared, 'form' => $form, 'view' => $view, 'storage' => $storage]); $classMetadata->addPropertyMetadata($propertyMetadata); } } return $classMetadata; }
protected function configureRoute(\Symfony\Component\Routing\Route $route, \ReflectionClass $class, \ReflectionMethod $method, $annot) { // defines the controller $route->setDefault('_controller', $class->getName() . '::' . $method->getName()); // verify the other callbacks $options = $annot->getOptions(); foreach ($options as $prop => &$values) { if (!in_array($prop, array('_after_middlewares', '_before_middlewares', '_converters'))) { continue; } if (empty($values)) { continue; } foreach ($values as &$value) { if (is_string($value) && $class->hasMethod($value)) { // call static method from class $value = array($class->getName(), $value); } } unset($value); // clear reference } unset($values); $route->setOptions($options); }
public function loadMetadataForClass(\ReflectionClass $class) { $classMetadata = new ClassMetadata($class->getName()); foreach ($class->getProperties() as $reflectionProperty) { foreach ($this->reader->getPropertyAnnotations($reflectionProperty) as $fieldAnnot) { $propertyMetadata = new PropertyMetadata($class->getName(), $reflectionProperty->getName()); if ($fieldAnnot instanceof BRIDGE\Entity) { /** * @var BRIDGE\Entity $fieldAnnot */ $propertyMetadata->targetObject = $fieldAnnot->targetEntity; $propertyMetadata->targetManager = $fieldAnnot->entityManager; $propertyMetadata->type = 'dbal'; $classMetadata->addPropertyMetadata($propertyMetadata); } if ($fieldAnnot instanceof BRIDGE\Document) { /** * @var BRIDGE\Document $fieldAnnot */ $propertyMetadata->targetObject = $fieldAnnot->targetDocument; $propertyMetadata->targetManager = $fieldAnnot->documentManager; $propertyMetadata->type = 'odm'; $classMetadata->addPropertyMetadata($propertyMetadata); } } } return $classMetadata; }
/** * Expands class name into full name. * @param string * @return string full name * @throws Nette\InvalidArgumentException */ public static function expandClassName($name, \ReflectionClass $rc) { if (empty($name)) { throw new Nette\InvalidArgumentException('Class name must not be empty.'); } elseif ($name === 'self') { return $rc->getName(); } elseif ($name[0] === '\\') { // fully qualified name return ltrim($name, '\\'); } $uses =& self::$cache[$rc->getName()]; if ($uses === NULL) { self::$cache = self::parseUseStatemenets(file_get_contents($rc->getFileName()), $rc->getName()) + self::$cache; $uses =& self::$cache[$rc->getName()]; } $parts = explode('\\', $name, 2); if (isset($uses[$parts[0]])) { $parts[0] = $uses[$parts[0]]; return implode('\\', $parts); } elseif ($rc->inNamespace()) { return $rc->getNamespaceName() . '\\' . $name; } else { return $name; } }
/** * @return \ReflectionClass */ public function getParentClass() { if (defined('HHVM_VERSION')) { return new ReflectionClass($this->reflectionClass->getName()); } return $this->reflectionClass; }
/** * Initializes a new ClassMetadata instance that will hold the object-document mapping * metadata of the class with the given name. * * @param string $documentName The name of the document class the new instance is used for. */ public function __construct($documentName) { parent::__construct($documentName); $this->reflClass = new \ReflectionClass($documentName); $this->name = $this->reflClass->getName(); $this->namespace = $this->reflClass->getNamespaceName(); }
/** * @param \ReflectionClass $class * * @return \ReflectionClass[] */ public function __invoke(\ReflectionClass $class) { if ($parentClass = $class->getParentClass()) { return array_merge([$class->getName() => $class], $this->__invoke($parentClass)); } return [$class->getName() => $class]; }
/** * Carrega os recursos controllers dos modulos da aplicacao. * @param $pathController * @param $module * @param string $parentClass - indica qual é a classe parent da classe, para saber se é um controller * @return mixed|string */ public function loadResourceControllerModule($parentClass = "Zend\\Mvc\\Controller\\AbstractActionController") { $resourcesController = array(); foreach ($this->getModulesSystem() as $module) { $pathDefaultControllersModule = './module/' . $module . '/src/' . $module . '/Controller/'; foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($pathDefaultControllersModule)) as $filename) { if ($filename->isDir()) { continue; } //criar um metodo para acomodar este tratamento $pathController = str_replace('./module/' . $module . '/src/', '', $filename); $pathController = str_replace('.php', '', $pathController); $pathController = "\\" . str_replace('/', "\\", $pathController); if ($pathController != "\\" . $module . "\\Controller\\AbstractController") { $oReflectionClass = new \ReflectionClass($pathController); if (is_subclass_of($oReflectionClass->getName(), $parentClass) || is_subclass_of($oReflectionClass->getName(), "Base\\Controller\\AbstractController")) { $actions = $this->loadResourceActionsController($oReflectionClass); if (!empty($actions)) { $resourcesController[$module][$oReflectionClass->getName()] = $actions; } } } } } return $resourcesController; }
private function discriminateClass(\ReflectionClass $class, array $data) { $properties = $class->getDefaultProperties(); if (!empty($properties["modelDiscriminatorMap"])) { $discriminator = $properties["modelDiscriminatorMap"]; if (empty($discriminator["discriminatorField"])) { throw new ModelException("Cannot use the discriminator map for '{$class->getName()}'. No discriminator field was configured."); } $field = $discriminator["discriminatorField"]; if (empty($data[$field])) { throw new ModelException("The discriminator field '{$field}' for '{$class->getName()}' was not found in the data set."); } $baseNamespace = !empty($discriminator["subclassNamespace"]) ? $discriminator["subclassNamespace"] : $class->getNamespaceName(); $classNameSuffix = !empty($discriminator["subclassSuffix"]) ? $discriminator["subclassSuffix"] : ""; $map = !empty($discriminator["map"]) ? $discriminator["map"] : []; // generate the class name $value = $data[$field]; if (empty($map[$value])) { throw new ModelException("The discriminator value '{$value}' was not registered in the map"); } $className = $map[$value] !== true ? $map[$value] : $this->toStudlyCaps($value); // if this is not a valid class, try it with the base namespace if (!class_exists($className)) { $className = $baseNamespace . "\\" . $className; if (!class_exists($className)) { $className .= $classNameSuffix; } } // create the reflection object. This will throw an exception if the class does not exist, as is expected. $class = new \ReflectionClass($className); } return $class; }
/** * @param $serviceId * @param $class * @param $method */ public function map($serviceId, $class, $method) { $class = new \ReflectionClass($class); $method = $class->getMethod($method); $annotations = []; $annotations[] = $this->reader->getMethodAnnotation($method, self::REGISTER_ANNOTATION_CLASS); $annotations[] = $this->reader->getMethodAnnotation($method, self::SUBSCRIBE_ANNOTATION_CLASS); $securityAnnotation = $this->reader->getMethodAnnotation($method, self::SECURITY_ANNOTATION_CLASS); /* @var $annotation Register */ foreach ($annotations as $annotation) { if ($annotation) { /* @var $workerAnnotation Register */ $workerAnnotation = isset($this->workerAnnotationsClasses[$class->getName()]) ? $this->workerAnnotationsClasses[$class->getName()] : null; if ($workerAnnotation) { $worker = $workerAnnotation->getName(); } else { $worker = $annotation->getWorker() ?: "default"; } $mapping = new URIClassMapping($serviceId, $method, $annotation); if (isset($this->mappings[$worker][$annotation->getName()])) { $uri = $annotation->getName(); $className = $this->mappings[$worker][$annotation->getName()]->getMethod()->class; throw new Exception("The URI '{$uri}' has already been registered in '{$className}' for the worker '{$worker}'"); } //Set security Annotation $mapping->setSecurityAnnotation($securityAnnotation); $this->mappings[$worker][$annotation->getName()] = $mapping; } } }
/** * @param string $controller * * @return array * @throws \ManaPHP\Authorization\Rbac\PermissionBuilder\Exception */ public function getControllerPermissions($controller) { $rc = new \ReflectionClass($controller); if (preg_match('#^[^/]*/([^/]*)/Controllers/(.*)Controller$#', str_replace('\\', '/', $controller), $match) !== 1) { return []; } $moduleName = $match[1]; $controllerName = $match[2]; $permissions = []; foreach ($rc->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) { $methodName = $method->getName(); if (preg_match('#^(.*)(Action)$#i', $methodName, $match) !== 1) { continue; } $actionName = $match[1]; if ($match[2] !== 'Action') { throw new PermissionBuilderException('`:action` action of `:controller` is not suffix with `Action`', ['controller' => $rc->getName(), 'action' => $methodName]); } if (!$method->isPublic()) { throw new PermissionBuilderException('`:action` action of `:controller` does not have public visibility.', ['controller' => $rc->getName(), 'action' => $methodName]); } $permissions[] = ['module' => $moduleName, 'controller' => $controllerName, 'action' => $actionName, 'description' => $moduleName . '::' . $controllerName . '::' . $actionName]; } return $permissions; }
/** * @param \ReflectionClass $class * * @return \Metadata\ClassMetadata */ public function loadMetadataForClass(\ReflectionClass $class) { $classMetadata = new ClassMetadata($class->getName()); foreach ($class->getMethods(\ReflectionMethod::IS_PUBLIC) as $reflectionMethod) { if (false === strpos($reflectionMethod->getName(), 'Action')) { continue; } if ($reflectionMethod->isAbstract()) { continue; } $methodMetadata = new ActionMetadata($class->getName(), $reflectionMethod->getName()); $annotations = $this->reader->getMethodAnnotations($reflectionMethod); foreach ($annotations as $annotation) { if ($annotation instanceof \BackBee\Rest\Controller\Annotations\QueryParam) { $data = array('name' => $annotation->name, 'key' => $annotation->key ? $annotation->key : $annotation->name, 'default' => $annotation->default, 'description' => $annotation->description, 'requirements' => $annotation->requirements); $methodMetadata->queryParams[] = $data; } elseif ($annotation instanceof \BackBee\Rest\Controller\Annotations\RequestParam) { $data = array('name' => $annotation->name, 'key' => $annotation->key ? $annotation->key : $annotation->name, 'default' => $annotation->default, 'description' => $annotation->description, 'requirements' => $annotation->requirements); $methodMetadata->requestParams[] = $data; } elseif ($annotation instanceof \BackBee\Rest\Controller\Annotations\Pagination) { $methodMetadata->default_start = $annotation->default_start; $methodMetadata->default_count = $annotation->default_count; $methodMetadata->max_count = $annotation->max_count; $methodMetadata->min_count = $annotation->min_count; } elseif ($annotation instanceof \BackBee\Rest\Controller\Annotations\ParamConverter) { $methodMetadata->param_converter_bag[] = $annotation; } elseif ($annotation instanceof \BackBee\Rest\Controller\Annotations\Security) { $methodMetadata->security[] = $annotation; } } $classMetadata->addMethodMetadata($methodMetadata); } return $classMetadata; }
/** * @return \Phalcon\Annotations\Collection */ private function getAnnotationClass() { $reader = new \Phalcon\Annotations\Reader(); $parsing = $reader->parse($this->refClass->getName()); //Create the reflection $annotations = new \Phalcon\Annotations\Reflection($parsing); return $annotations->getClassAnnotations(); }
/** * @param string $method * @param array $arguments * @return $this * @throws \Phur\Builder\Exception */ public function __call($method, array $arguments) { if (!$this->productClass->hasMethod($method) && !$this->productClass->hasMethod('__call')) { throw new Exception($this->productClass->getName() . "::{$method}() is not callable!"); } $this->configuration[] = array($method, $arguments); return $this; }
/** * @todo ? refactoring visual reflection for Igor * Get constant value by name * if const like $strName not exists - exception throwed * * @param string $strName * @throws System_Enum_Exception * @return mixed */ public function getValue($strName) { $value = $this->_objReflection->getConstant($strName); if ($value === FALSE) { throw new Core_Enum_Exception($strName . ' name not found in ' . $this->_objReflection->getName()); } return $value; }
/** * Get Class definition for constructor parameter. * * @param \ReflectionClass $parameterClass * * @return mixed|null|object */ private function getClassDefinition(\ReflectionClass $parameterClass) { $parameterClassName = $parameterClass->getName(); $entryReference = new \ReflectionClass($parameterClass->getName()); $argumentParams = false; if ($entryReference->getConstructor()) { $argumentParams = $entryReference->getConstructor()->getParameters(); } return $argumentParams ? $this->get($parameterClassName) : new $parameterClassName(); }
public function findCachedClassByReflectionClass(ReflectionClass $reflectionClass) { foreach (AbstractMappedClassLoader::$cachedClasses as $cachedClass) { // $cachedClass = new MappedClass(); if (!$cachedClass->isPrimitive() && $cachedClass->getReflectionClass() != null && $cachedClass->getReflectionClass()->getName() == $reflectionClass->getName() && $cachedClass->getReflectionClass()->getFileName() == $reflectionClass->getName()) { return $cachedClass; } } return null; }
/** * Test class definition */ public function testClassDefinition() { $class = new \ReflectionClass('O2\\Bundle\\UIBundle\\Twig\\Extension\\FlashAlertsExtension'); $methods = array('addError', 'addWarning', 'addSuccess', 'addInfo', 'flashMessages'); foreach ($methods as $method) { $this->assertTrue($class->hasMethod($method), sprintf('Class %s does not have method ', $class->getName(), $method)); } $this->assertClassHasAttribute('session', $class->getName()); $this->assertClassHasAttribute('environment', $class->getName()); }
/** * Check whether it is allowed to clean given class static variables * * @param \ReflectionClass $reflectionClass * @return bool */ protected static function _isClassCleanable(\ReflectionClass $reflectionClass) { // do not process blacklisted classes from integration framework foreach (self::$_classesToSkip as $notCleanableClass) { if ($reflectionClass->getName() == $notCleanableClass || is_subclass_of($reflectionClass->getName(), $notCleanableClass)) { return false; } } return true; }
/** * @return bool */ protected function calcHasOwnMethods() { $class = $this->reflectionClass->getName(); foreach ($this->reflectionClass->getMethods() as $reflectionMethod) { if ($class === $reflectionMethod->getDeclaringClass()->getName()) { return TRUE; } } return FALSE; }
/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { if (!class_exists($arguments['class'])) { throw new InvalidArgumentException(sprintf('The class "%s" could not be found.', $arguments['class'])); } $r = new ReflectionClass($arguments['class']); if (0 !== strpos($r->getFilename(), sfConfig::get('sf_lib_dir'))) { throw new InvalidArgumentException(sprintf('The class "%s" is not located in the project lib/ directory.', $r->getName())); } $path = str_replace(sfConfig::get('sf_lib_dir'), '', dirname($r->getFilename())); $test = sfConfig::get('sf_test_dir') . '/unit' . $path . '/' . $r->getName() . 'Test.php'; if (file_exists($test)) { if ($options['force']) { $this->getFilesystem()->remove($test); } else { $this->logSection('task', sprintf('A test script for the class "%s" already exists.', $r->getName())); if (isset($options['editor-cmd'])) { $this->getFilesystem()->sh($options['editor-cmd'] . ' ' . $test); } return 1; } } $template = ''; $database = false; if (!$options['disable-defaults']) { if ($r->isSubClassOf('sfForm')) { $options['without-methods'] = true; if (!$r->isAbstract()) { $template = 'Form'; } } if (class_exists('Propel') && ($r->isSubclassOf('BaseObject') || 'Peer' == substr($r->getName(), -4) || $r->isSubclassOf('sfFormPropel')) || class_exists('Doctrine') && ($r->isSubclassOf('Doctrine_Record') || $r->isSubclassOf('Doctrine_Table') || $r->isSubclassOf('sfFormDoctrine')) || $r->isSubclassOf('sfFormFilter')) { $database = true; } } $tests = ''; if (!$options['without-methods']) { foreach ($r->getMethods() as $method) { if ($method->getDeclaringClass()->getName() == $r->getName() && $method->isPublic()) { $type = $method->isStatic() ? '::' : '->'; $tests .= <<<EOF // {$type}{$method->getName()}() \$t->diag('{$type}{$method->getName()}()'); EOF; } } } $this->getFilesystem()->copy(dirname(__FILE__) . sprintf('/skeleton/test/UnitTest%s.php', $template), $test); $this->getFilesystem()->replaceTokens($test, '##', '##', array('CLASS' => $r->getName(), 'TEST_DIR' => str_repeat('/..', substr_count($path, DIRECTORY_SEPARATOR) + 1), 'TESTS' => $tests, 'DATABASE' => $database ? "\n\$databaseManager = new sfDatabaseManager(\$configuration);\n" : '')); if (isset($options['editor-cmd'])) { $this->getFilesystem()->sh($options['editor-cmd'] . ' ' . $test); } }
/** * @param \ReflectionClass $class * @param $annotationName * @return mixed */ private function getAnnotation(\ReflectionClass $class, $annotationName) { if (isset($this->annotations[$class->getName()][$annotationName])) { return $this->annotations[$class->getName()][$annotationName]; } $reader = new AnnotationReader(); if ($annotation = $reader->getClassAnnotation($class, $annotationName)) { $this->annotations[$class->getName()][$annotationName] = $annotation; } return $annotation; }
protected function loadMetadataFromFile(\ReflectionClass $class, $file) { $metadata = (require $file); if (!$metadata instanceof ClassMetadata) { throw new \RuntimeException(sprintf('The file %s was expected to return an instance of ClassMetadata, but returned %s.', $file, json_encode($metadata))); } if ($metadata->name !== $class->getName()) { throw new \RuntimeException(sprintf('The file %s was expected to return metadata for class %s, but instead returned metadata for class %s.', $class->getName(), $metadata->name)); } return $metadata; }
/** * @return string * @throws IncompatibleAggregateException */ public function getIdentifier() { foreach (ReflectionUtils::getProperties($this->reflectionClass) as $property) { $annotation = $this->reader->getPropertyAnnotation($property, AggregateIdentifier::class); if (null !== $annotation) { $property->setAccessible(true); return $property->getValue($this->targetObject); } } throw new IncompatibleAggregateException(sprintf("The aggregate class [%s] does not specify an Identifier. " . "Ensure that the field containing the aggregate " . "identifier is annotated with @AggregateIdentifier.", $this->reflectionClass->getName())); }
/** Write message to log and if necessary raise it to stderr to trigger an email @param $str message string @param $severity [optional, default 6/info] message importance @return empty string */ public function cronMsg($str, $severity = 6) { $info = new ReflectionClass($this); $msg = date('r') . ': ' . $info->getName() . ': ' . $str . "\n"; $this->logger->log($severity, $info->getName() . ': ' . $str); // raise message into stderr if ($severity <= $this->error_threshold) { file_put_contents('php://stderr', $msg, FILE_APPEND); } return ''; }