本文整理汇总了PHP中Symfony\Component\DependencyInjection\Definition::isAbstract方法的典型用法代码示例。如果您正苦于以下问题:PHP Definition::isAbstract方法的具体用法?PHP Definition::isAbstract怎么用?PHP Definition::isAbstract使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\DependencyInjection\Definition
的用法示例。
在下文中一共展示了Definition::isAbstract方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
public function validate(Definition $definition) : bool
{
if (!$definition->isPublic() || $definition->isAbstract()) {
return false;
}
if (null === $definition->getClass() || !class_exists($definition->getClass())) {
return false;
}
return true;
}
示例2: canBeAdded
/**
* @return bool
*/
private function canBeAdded(Definition $definition)
{
if ($definition->isAbstract()) {
return false;
}
if (!$definition->isPublic()) {
return false;
}
if (!$definition->getClass()) {
return false;
}
return true;
}
示例3: validate
public function validate(Definition $definition)
{
if ($definition->isAbstract()) {
return;
}
if ($definition->isSynthetic()) {
return;
}
$constructor = $this->constructorResolver->resolve($definition);
if ($constructor === null) {
return;
}
$arguments = $definition->getArguments();
$this->argumentsValidator->validate($constructor, array_values($arguments));
}
开发者ID:bendavies,项目名称:symfony-service-definition-validator,代码行数:15,代码来源:DefinitionArgumentsValidator.php
示例4: populateAvailableTypes
private function populateAvailableTypes($id, Definition $definition)
{
if ($definition->isAbstract()) {
return;
}
foreach ($definition->getAutowiringTypes() as $type) {
$this->definedTypes[$type] = true;
$this->types[$type][] = $id;
}
if (!($reflectionClass = $this->getReflectionClass($id, $definition))) {
return;
}
foreach ($reflectionClass->getInterfaces() as $reflectionInterface) {
$this->set($reflectionInterface->name, $id);
}
do {
$this->set($reflectionClass->name, $id);
} while ($reflectionClass = $reflectionClass->getParentClass());
}
示例5: validate
/**
* Checks if the definition is valid.
*
* @param ContainerBuilder $container The container.
* @param Definition $definition The definition.
* @param string $id The identifier.
* @param array $tag The tag data.
*
* @throws DefinitionException If the definition is not valid.
*/
protected function validate(ContainerBuilder $container, Definition $definition, $id, array $tag)
{
if ($definition->isAbstract()) {
throw DefinitionException::taggedServiceAbstract($id, $this->tag);
// @codeCoverageIgnore
}
if (!$definition->isPublic()) {
throw DefinitionException::taggedServiceNotPublic($id, $this->tag);
// @codeCoverageIgnore
}
if (null !== $this->parent) {
$reflection = new ReflectionClass($container->getParameterBag()->resolveValue($definition->getClass()));
// @codeCoverageIgnoreStart
if (!$reflection->isSubclassOf($this->parent)) {
throw DefinitionException::taggedServiceNotSubclass($id, $this->tag, $this->parent);
}
// @codeCoverageIgnoreEnd
}
}
示例6: getContainerDefinitionDocument
/**
* @param Definition $definition
* @param string|null $id
* @param bool $omitTags
*
* @return \DOMDocument
*/
private function getContainerDefinitionDocument(Definition $definition, $id = null, $omitTags = false)
{
$dom = new \DOMDocument('1.0', 'UTF-8');
$dom->appendChild($serviceXML = $dom->createElement('definition'));
if ($id) {
$serviceXML->setAttribute('id', $id);
}
$serviceXML->setAttribute('class', $definition->getClass());
if ($definition->getFactoryClass()) {
$serviceXML->setAttribute('factory-class', $definition->getFactoryClass());
}
if ($definition->getFactoryService()) {
$serviceXML->setAttribute('factory-service', $definition->getFactoryService());
}
if ($definition->getFactoryMethod()) {
$serviceXML->setAttribute('factory-method', $definition->getFactoryMethod());
}
$serviceXML->setAttribute('scope', $definition->getScope());
$serviceXML->setAttribute('public', $definition->isPublic() ? 'true' : 'false');
$serviceXML->setAttribute('synthetic', $definition->isSynthetic() ? 'true' : 'false');
$serviceXML->setAttribute('lazy', $definition->isLazy() ? 'true' : 'false');
$serviceXML->setAttribute('synchronized', $definition->isSynchronized() ? 'true' : 'false');
$serviceXML->setAttribute('abstract', $definition->isAbstract() ? 'true' : 'false');
$serviceXML->setAttribute('file', $definition->getFile());
if (!$omitTags) {
$tags = $definition->getTags();
if (count($tags) > 0) {
$serviceXML->appendChild($tagsXML = $dom->createElement('tags'));
foreach ($tags as $tagName => $tagData) {
foreach ($tagData as $parameters) {
$tagsXML->appendChild($tagXML = $dom->createElement('tag'));
$tagXML->setAttribute('name', $tagName);
foreach ($parameters as $name => $value) {
$tagXML->appendChild($parameterXML = $dom->createElement('parameter'));
$parameterXML->setAttribute('name', $name);
$parameterXML->appendChild(new \DOMText($this->formatParameter($value)));
}
}
}
}
}
return $dom;
}
示例7: describeContainerDefinition
/**
* {@inheritdoc}
*/
protected function describeContainerDefinition(Definition $definition, array $options = array())
{
$description = isset($options['id']) ? array($this->formatSection('container', sprintf('Information for service <info>%s</info>', $options['id']))) : array();
$description[] = sprintf('<comment>Service Id</comment> %s', isset($options['id']) ? $options['id'] : '-');
$description[] = sprintf('<comment>Class</comment> %s', $definition->getClass() ?: "-");
$tags = $definition->getTags();
if (count($tags)) {
$description[] = '<comment>Tags</comment>';
foreach ($tags as $tagName => $tagData) {
foreach ($tagData as $parameters) {
$description[] = sprintf(' - %-30s (%s)', $tagName, implode(', ', array_map(function ($key, $value) {
return sprintf('<info>%s</info>: %s', $key, $value);
}, array_keys($parameters), array_values($parameters))));
}
}
} else {
$description[] = '<comment>Tags</comment> -';
}
$description[] = sprintf('<comment>Scope</comment> %s', $definition->getScope());
$description[] = sprintf('<comment>Public</comment> %s', $definition->isPublic() ? 'yes' : 'no');
$description[] = sprintf('<comment>Synthetic</comment> %s', $definition->isSynthetic() ? 'yes' : 'no');
$description[] = sprintf('<comment>Lazy</comment> %s', $definition->isLazy() ? 'yes' : 'no');
$description[] = sprintf('<comment>Synchronized</comment> %s', $definition->isSynchronized() ? 'yes' : 'no');
$description[] = sprintf('<comment>Abstract</comment> %s', $definition->isAbstract() ? 'yes' : 'no');
if ($definition->getFile()) {
$description[] = sprintf('<comment>Required File</comment> %s', $definition->getFile() ? $definition->getFile() : '-');
}
if ($definition->getFactoryClass()) {
$description[] = sprintf('<comment>Factory Class</comment> %s', $definition->getFactoryClass());
}
if ($definition->getFactoryService()) {
$description[] = sprintf('<comment>Factory Service</comment> %s', $definition->getFactoryService());
}
if ($definition->getFactoryMethod()) {
$description[] = sprintf('<comment>Factory Method</comment> %s', $definition->getFactoryMethod());
}
if ($factory = $definition->getFactory()) {
if (is_array($factory)) {
if ($factory[0] instanceof Reference) {
$description[] = sprintf('<comment>Factory Service</comment> %s', $factory[0]);
} elseif ($factory[0] instanceof Definition) {
throw new \InvalidArgumentException('Factory is not describable.');
} else {
$description[] = sprintf('<comment>Factory Class</comment> %s', $factory[0]);
}
$description[] = sprintf('<comment>Factory Method</comment> %s', $factory[1]);
} else {
$description[] = sprintf('<comment>Factory Function</comment> %s', $factory);
}
}
$this->writeText(implode("\n", $description) . "\n", $options);
}
示例8: describeContainerDefinition
/**
* {@inheritdoc}
*/
protected function describeContainerDefinition(Definition $definition, array $options = array())
{
$output = '- Class: `' . $definition->getClass() . '`' . "\n" . '- Scope: `' . $definition->getScope() . '`' . "\n" . '- Public: ' . ($definition->isPublic() ? 'yes' : 'no') . "\n" . '- Synthetic: ' . ($definition->isSynthetic() ? 'yes' : 'no') . "\n" . '- Lazy: ' . ($definition->isLazy() ? 'yes' : 'no') . "\n" . '- Synchronized: ' . ($definition->isSynchronized() ? 'yes' : 'no') . "\n" . '- Abstract: ' . ($definition->isAbstract() ? 'yes' : 'no');
if ($definition->getFile()) {
$output .= "\n" . '- File: `' . $definition->getFile() . '`';
}
if ($definition->getFactoryClass()) {
$output .= "\n" . '- Factory Class: `' . $definition->getFactoryClass() . '`';
}
if ($definition->getFactoryService()) {
$output .= "\n" . '- Factory Service: `' . $definition->getFactoryService() . '`';
}
if ($definition->getFactoryMethod()) {
$output .= "\n" . '- Factory Method: `' . $definition->getFactoryMethod() . '`';
}
if ($factory = $definition->getFactory()) {
if (is_array($factory)) {
if ($factory[0] instanceof Reference) {
$output .= "\n" . '- Factory Service: `' . $factory[0] . '`';
} elseif ($factory[0] instanceof Definition) {
throw new \InvalidArgumentException('Factory is not describable.');
} else {
$output .= "\n" . '- Factory Class: `' . $factory[0] . '`';
}
$output .= "\n" . '- Factory Method: `' . $factory[1] . '`';
} else {
$output .= "\n" . '- Factory Function: `' . $factory . '`';
}
}
if (!(isset($options['omit_tags']) && $options['omit_tags'])) {
foreach ($definition->getTags() as $tagName => $tagData) {
foreach ($tagData as $parameters) {
$output .= "\n" . '- Tag: `' . $tagName . '`';
foreach ($parameters as $name => $value) {
$output .= "\n" . ' - ' . ucfirst($name) . ': ' . $value;
}
}
}
}
$this->write(isset($options['id']) ? sprintf("%s\n%s\n\n%s\n", $options['id'], str_repeat('~', strlen($options['id'])), $output) : $output);
}
示例9: getContainerDefinitionDocument
/**
* @param Definition $definition
* @param string|null $id
* @param bool $omitTags
*
* @return \DOMDocument
*/
private function getContainerDefinitionDocument(Definition $definition, $id = null, $omitTags = false)
{
$dom = new \DOMDocument('1.0', 'UTF-8');
$dom->appendChild($serviceXML = $dom->createElement('definition'));
if ($id) {
$serviceXML->setAttribute('id', $id);
}
$serviceXML->setAttribute('class', $definition->getClass());
if ($definition->getFactoryClass()) {
$serviceXML->setAttribute('factory-class', $definition->getFactoryClass());
}
if ($definition->getFactoryService()) {
$serviceXML->setAttribute('factory-service', $definition->getFactoryService());
}
if ($definition->getFactoryMethod()) {
$serviceXML->setAttribute('factory-method', $definition->getFactoryMethod());
}
if ($factory = $definition->getFactory()) {
$serviceXML->appendChild($factoryXML = $dom->createElement('factory'));
if (is_array($factory)) {
if ($factory[0] instanceof Reference) {
$factoryXML->setAttribute('service', (string) $factory[0]);
} elseif ($factory[0] instanceof Definition) {
throw new \InvalidArgumentException('Factory is not describable.');
} else {
$factoryXML->setAttribute('class', $factory[0]);
}
$factoryXML->setAttribute('method', $factory[1]);
} else {
$factoryXML->setAttribute('function', $factory);
}
}
$serviceXML->setAttribute('scope', $definition->getScope());
$serviceXML->setAttribute('public', $definition->isPublic() ? 'true' : 'false');
$serviceXML->setAttribute('synthetic', $definition->isSynthetic() ? 'true' : 'false');
$serviceXML->setAttribute('lazy', $definition->isLazy() ? 'true' : 'false');
$serviceXML->setAttribute('synchronized', $definition->isSynchronized() ? 'true' : 'false');
$serviceXML->setAttribute('abstract', $definition->isAbstract() ? 'true' : 'false');
$serviceXML->setAttribute('file', $definition->getFile());
if (!$omitTags) {
$tags = $definition->getTags();
if (count($tags) > 0) {
$serviceXML->appendChild($tagsXML = $dom->createElement('tags'));
foreach ($tags as $tagName => $tagData) {
foreach ($tagData as $parameters) {
$tagsXML->appendChild($tagXML = $dom->createElement('tag'));
$tagXML->setAttribute('name', $tagName);
foreach ($parameters as $name => $value) {
$tagXML->appendChild($parameterXML = $dom->createElement('parameter'));
$parameterXML->setAttribute('name', $name);
$parameterXML->appendChild(new \DOMText($this->formatParameter($value)));
}
}
}
}
}
return $dom;
}
示例10: validateDefinition
/**
* Validates the service definition.
*
* An exception is thrown if the following conditions are not met:
*
* - The service is public.
* - The service is not abstract.
* - The service implements an interface or is a subclass.
*
* @param ContainerBuilder $container The container builder.
* @param Definition $definition The service definition.
* @param string $class The FQIN or FQCN.
* @param string $id The service identifier.
*
* @throws ServiceException If the definition is not valid.
*/
private function validateDefinition(ContainerBuilder $container, Definition $definition, $class, $id)
{
if ($definition->isAbstract()) {
throw new ServiceException("The service definition \"{$id}\" is abstract.");
}
if (!$definition->isPublic()) {
throw new ServiceException("The service definition \"{$id}\" is private.");
}
$reflection = new ReflectionClass($container->getParameterBag()->resolveValue($definition->getClass()));
if ($reflection->isInterface() || !$reflection->isSubclassOf($class)) {
$expected = new ReflectionClass($class);
if ($expected->isInterface() || $class !== $reflection->getName()) {
throw new ServiceException(sprintf('The service definition "%s" does not implement or extend "%s".', $id, $class));
}
}
}
示例11: shouldDefinitionHaveAClass
/**
* Find out whether or not the given definition should have a class (i.e. not when it is a synthetic or abstract
* definition)
*
* @param Definition $definition
* @return bool
*/
private function shouldDefinitionHaveAClass(Definition $definition)
{
if ($definition->isSynthetic()) {
return false;
}
if ($definition->isAbstract()) {
return false;
}
return true;
}
示例12: hydrateDefinitionAbstractProperty
/**
* Try to hydrate definition abstract property from entity into definition array.
*
* @param Definition $definition the definition to convert
* @param array $definitionArray the definition array (passed by reference)
*/
private function hydrateDefinitionAbstractProperty(Definition $definition, array &$definitionArray)
{
if ($definition->isAbstract()) {
$definitionArray['abstract'] = true;
}
}
示例13: populateAvailableType
/**
* Populates the list of available types for a given definition.
*
* @param string $id
* @param Definition $definition
*/
private function populateAvailableType($id, Definition $definition)
{
// Never use abstract services
if ($definition->isAbstract()) {
return;
}
foreach ($definition->getAutowiringTypes() as $type) {
$this->definedTypes[$type] = true;
$this->types[$type] = $id;
}
// Cannot use reflection if the class isn't set
if (!$definition->getClass()) {
return;
}
if ($reflectionClass = $this->getReflectionClass($id, $definition)) {
$this->extractInterfaces($id, $reflectionClass);
$this->extractAncestors($id, $reflectionClass);
}
}
示例14: getContainerDefinitionData
/**
* @param Definition $definition
* @param bool $omitTags
*
* @return array
*/
private function getContainerDefinitionData(Definition $definition, $omitTags = false)
{
$data = array('class' => (string) $definition->getClass(), 'scope' => $definition->getScope(), 'public' => $definition->isPublic(), 'synthetic' => $definition->isSynthetic(), 'lazy' => $definition->isLazy(), 'synchronized' => $definition->isSynchronized(), 'abstract' => $definition->isAbstract(), 'file' => $definition->getFile());
if ($definition->getFactoryClass()) {
$data['factory_class'] = $definition->getFactoryClass();
}
if ($definition->getFactoryService()) {
$data['factory_service'] = $definition->getFactoryService();
}
if ($definition->getFactoryMethod()) {
$data['factory_method'] = $definition->getFactoryMethod();
}
if ($factory = $definition->getFactory()) {
if (is_array($factory)) {
if ($factory[0] instanceof Reference) {
$data['factory_service'] = (string) $factory[0];
} elseif ($factory[0] instanceof Definition) {
throw new \InvalidArgumentException('Factory is not describable.');
} else {
$data['factory_class'] = $factory[0];
}
$data['factory_method'] = $factory[1];
} else {
$data['factory_function'] = $factory;
}
}
if (!$omitTags) {
$data['tags'] = array();
if (count($definition->getTags())) {
foreach ($definition->getTags() as $tagName => $tagData) {
foreach ($tagData as $parameters) {
$data['tags'][] = array('name' => $tagName, 'parameters' => $parameters);
}
}
}
}
return $data;
}
示例15: canDefinitionBeAutowired
/**
* @param string $serviceId
* @param Definition $definition
* @return boolean
*/
private function canDefinitionBeAutowired($serviceId, Definition $definition)
{
foreach ($this->getIgnoredServicePatterns() as $pattern) {
if ($pattern[0] === "/" && preg_match($pattern, $serviceId) || strcasecmp($serviceId, $pattern) == 0) {
return false;
}
}
if ($definition->isAbstract() || $definition->isSynthetic() || !$definition->isPublic() || !$definition->getClass() || $definition->getFactory() || $definition->getFactoryClass(false) || $definition->getFactoryService(false) || $definition->getFactoryMethod(false)) {
return false;
}
return true;
}