Neos\Flow\Reflection\ReflectionService::getClassSchema PHP 메소드

getClassSchema() 공개 메소드

Returns the class schema for the given class
public getClassSchema ( mixed $classNameOrObject ) : ClassSchema
$classNameOrObject mixed The class name or an object
리턴 ClassSchema
    public function getClassSchema($classNameOrObject)
    {
        $className = $classNameOrObject;
        if (is_object($classNameOrObject)) {
            $className = get_class($classNameOrObject);
        }
        $className = $this->cleanClassName($className);
        if (!isset($this->classSchemata[$className])) {
            $this->classSchemata[$className] = $this->classSchemataRuntimeCache->get($this->produceCacheIdentifierFromClassName($className));
        }
        return is_object($this->classSchemata[$className]) ? $this->classSchemata[$className] : null;
    }

Usage Example

 /**
  * Generate a view with the given name for the given package and controller
  *
  * @param string $packageKey The package key of the controller's package
  * @param string $subpackage An optional subpackage name
  * @param string $controllerName The name of the new controller
  * @param string $viewName The name of the view
  * @param string $templateName The name of the view
  * @param boolean $overwrite Overwrite any existing files?
  * @return array An array of generated filenames
  */
 public function generateView($packageKey, $subpackage, $controllerName, $viewName, $templateName, $overwrite = false)
 {
     list($baseNamespace) = $this->getPrimaryNamespaceAndEntryPath($this->packageManager->getPackage($packageKey));
     $viewName = ucfirst($viewName);
     $templatePathAndFilename = 'resource://Neos.Kickstarter/Private/Generator/View/' . $templateName . 'Template.html';
     $contextVariables = array();
     $contextVariables['packageKey'] = $packageKey;
     $contextVariables['subpackage'] = $subpackage;
     $contextVariables['isInSubpackage'] = $subpackage != '';
     $contextVariables['controllerName'] = $controllerName;
     $contextVariables['viewName'] = $viewName;
     $contextVariables['modelName'] = strtolower($controllerName[0]) . substr($controllerName, 1);
     $contextVariables['repositoryClassName'] = '\\' . trim($baseNamespace, '\\') . ($subpackage != '' ? '\\' . $subpackage : '') . '\\Domain\\Repository\\' . $controllerName . 'Repository';
     $contextVariables['modelFullClassName'] = '\\' . trim($baseNamespace, '\\') . ($subpackage != '' ? '\\' . $subpackage : '') . '\\Domain\\Model\\' . $controllerName;
     $contextVariables['modelClassName'] = ucfirst($contextVariables['modelName']);
     $modelClassSchema = $this->reflectionService->getClassSchema($contextVariables['modelFullClassName']);
     if ($modelClassSchema !== null) {
         $contextVariables['properties'] = $modelClassSchema->getProperties();
         if (isset($contextVariables['properties']['Persistence_Object_Identifier'])) {
             unset($contextVariables['properties']['Persistence_Object_Identifier']);
         }
     }
     if (!isset($contextVariables['properties']) || $contextVariables['properties'] === array()) {
         $contextVariables['properties'] = array('name' => array('type' => 'string'));
     }
     $fileContent = $this->renderTemplate($templatePathAndFilename, $contextVariables);
     $subpackagePath = $subpackage != '' ? $subpackage . '/' : '';
     $viewFilename = $viewName . '.html';
     $viewPath = 'resource://' . $packageKey . '/Private/Templates/' . $subpackagePath . $controllerName . '/';
     $targetPathAndFilename = $viewPath . $viewFilename;
     $this->generateFile($targetPathAndFilename, $fileContent, $overwrite);
     return $this->generatedFiles;
 }
All Usage Examples Of Neos\Flow\Reflection\ReflectionService::getClassSchema
ReflectionService