annotate vendor/symfony/dependency-injection/Definition.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children 7a779792577d
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 /*
Chris@0 4 * This file is part of the Symfony package.
Chris@0 5 *
Chris@0 6 * (c) Fabien Potencier <fabien@symfony.com>
Chris@0 7 *
Chris@0 8 * For the full copyright and license information, please view the LICENSE
Chris@0 9 * file that was distributed with this source code.
Chris@0 10 */
Chris@0 11
Chris@0 12 namespace Symfony\Component\DependencyInjection;
Chris@0 13
Chris@0 14 use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
Chris@0 15 use Symfony\Component\DependencyInjection\Exception\OutOfBoundsException;
Chris@0 16
Chris@0 17 /**
Chris@0 18 * Definition represents a service definition.
Chris@0 19 *
Chris@0 20 * @author Fabien Potencier <fabien@symfony.com>
Chris@0 21 */
Chris@0 22 class Definition
Chris@0 23 {
Chris@0 24 private $class;
Chris@0 25 private $file;
Chris@0 26 private $factory;
Chris@0 27 private $shared = true;
Chris@0 28 private $deprecated = false;
Chris@0 29 private $deprecationTemplate = 'The "%service_id%" service is deprecated. You should stop using it, as it will soon be removed.';
Chris@0 30 private $properties = array();
Chris@0 31 private $calls = array();
Chris@0 32 private $configurator;
Chris@0 33 private $tags = array();
Chris@0 34 private $public = true;
Chris@0 35 private $synthetic = false;
Chris@0 36 private $abstract = false;
Chris@0 37 private $lazy = false;
Chris@0 38 private $decoratedService;
Chris@0 39 private $autowired = false;
Chris@0 40 private $autowiringTypes = array();
Chris@0 41
Chris@0 42 protected $arguments;
Chris@0 43
Chris@0 44 /**
Chris@0 45 * @param string|null $class The service class
Chris@0 46 * @param array $arguments An array of arguments to pass to the service constructor
Chris@0 47 */
Chris@0 48 public function __construct($class = null, array $arguments = array())
Chris@0 49 {
Chris@0 50 $this->class = $class;
Chris@0 51 $this->arguments = $arguments;
Chris@0 52 }
Chris@0 53
Chris@0 54 /**
Chris@0 55 * Sets a factory.
Chris@0 56 *
Chris@0 57 * @param string|array $factory A PHP function or an array containing a class/Reference and a method to call
Chris@0 58 *
Chris@0 59 * @return $this
Chris@0 60 */
Chris@0 61 public function setFactory($factory)
Chris@0 62 {
Chris@0 63 if (is_string($factory) && strpos($factory, '::') !== false) {
Chris@0 64 $factory = explode('::', $factory, 2);
Chris@0 65 }
Chris@0 66
Chris@0 67 $this->factory = $factory;
Chris@0 68
Chris@0 69 return $this;
Chris@0 70 }
Chris@0 71
Chris@0 72 /**
Chris@0 73 * Gets the factory.
Chris@0 74 *
Chris@0 75 * @return string|array The PHP function or an array containing a class/Reference and a method to call
Chris@0 76 */
Chris@0 77 public function getFactory()
Chris@0 78 {
Chris@0 79 return $this->factory;
Chris@0 80 }
Chris@0 81
Chris@0 82 /**
Chris@0 83 * Sets the service that this service is decorating.
Chris@0 84 *
Chris@0 85 * @param null|string $id The decorated service id, use null to remove decoration
Chris@0 86 * @param null|string $renamedId The new decorated service id
Chris@0 87 * @param int $priority The priority of decoration
Chris@0 88 *
Chris@0 89 * @return $this
Chris@0 90 *
Chris@0 91 * @throws InvalidArgumentException In case the decorated service id and the new decorated service id are equals.
Chris@0 92 */
Chris@0 93 public function setDecoratedService($id, $renamedId = null, $priority = 0)
Chris@0 94 {
Chris@0 95 if ($renamedId && $id == $renamedId) {
Chris@0 96 throw new InvalidArgumentException(sprintf('The decorated service inner name for "%s" must be different than the service name itself.', $id));
Chris@0 97 }
Chris@0 98
Chris@0 99 if (null === $id) {
Chris@0 100 $this->decoratedService = null;
Chris@0 101 } else {
Chris@0 102 $this->decoratedService = array($id, $renamedId, (int) $priority);
Chris@0 103 }
Chris@0 104
Chris@0 105 return $this;
Chris@0 106 }
Chris@0 107
Chris@0 108 /**
Chris@0 109 * Gets the service that this service is decorating.
Chris@0 110 *
Chris@0 111 * @return null|array An array composed of the decorated service id, the new id for it and the priority of decoration, null if no service is decorated
Chris@0 112 */
Chris@0 113 public function getDecoratedService()
Chris@0 114 {
Chris@0 115 return $this->decoratedService;
Chris@0 116 }
Chris@0 117
Chris@0 118 /**
Chris@0 119 * Sets the service class.
Chris@0 120 *
Chris@0 121 * @param string $class The service class
Chris@0 122 *
Chris@0 123 * @return $this
Chris@0 124 */
Chris@0 125 public function setClass($class)
Chris@0 126 {
Chris@0 127 $this->class = $class;
Chris@0 128
Chris@0 129 return $this;
Chris@0 130 }
Chris@0 131
Chris@0 132 /**
Chris@0 133 * Gets the service class.
Chris@0 134 *
Chris@0 135 * @return string|null The service class
Chris@0 136 */
Chris@0 137 public function getClass()
Chris@0 138 {
Chris@0 139 return $this->class;
Chris@0 140 }
Chris@0 141
Chris@0 142 /**
Chris@0 143 * Sets the arguments to pass to the service constructor/factory method.
Chris@0 144 *
Chris@0 145 * @param array $arguments An array of arguments
Chris@0 146 *
Chris@0 147 * @return $this
Chris@0 148 */
Chris@0 149 public function setArguments(array $arguments)
Chris@0 150 {
Chris@0 151 $this->arguments = $arguments;
Chris@0 152
Chris@0 153 return $this;
Chris@0 154 }
Chris@0 155
Chris@0 156 public function setProperties(array $properties)
Chris@0 157 {
Chris@0 158 $this->properties = $properties;
Chris@0 159
Chris@0 160 return $this;
Chris@0 161 }
Chris@0 162
Chris@0 163 public function getProperties()
Chris@0 164 {
Chris@0 165 return $this->properties;
Chris@0 166 }
Chris@0 167
Chris@0 168 public function setProperty($name, $value)
Chris@0 169 {
Chris@0 170 $this->properties[$name] = $value;
Chris@0 171
Chris@0 172 return $this;
Chris@0 173 }
Chris@0 174
Chris@0 175 /**
Chris@0 176 * Adds an argument to pass to the service constructor/factory method.
Chris@0 177 *
Chris@0 178 * @param mixed $argument An argument
Chris@0 179 *
Chris@0 180 * @return $this
Chris@0 181 */
Chris@0 182 public function addArgument($argument)
Chris@0 183 {
Chris@0 184 $this->arguments[] = $argument;
Chris@0 185
Chris@0 186 return $this;
Chris@0 187 }
Chris@0 188
Chris@0 189 /**
Chris@0 190 * Sets a specific argument.
Chris@0 191 *
Chris@0 192 * @param int $index
Chris@0 193 * @param mixed $argument
Chris@0 194 *
Chris@0 195 * @return $this
Chris@0 196 *
Chris@0 197 * @throws OutOfBoundsException When the replaced argument does not exist
Chris@0 198 */
Chris@0 199 public function replaceArgument($index, $argument)
Chris@0 200 {
Chris@0 201 if (0 === count($this->arguments)) {
Chris@0 202 throw new OutOfBoundsException('Cannot replace arguments if none have been configured yet.');
Chris@0 203 }
Chris@0 204
Chris@0 205 if ($index < 0 || $index > count($this->arguments) - 1) {
Chris@0 206 throw new OutOfBoundsException(sprintf('The index "%d" is not in the range [0, %d].', $index, count($this->arguments) - 1));
Chris@0 207 }
Chris@0 208
Chris@0 209 $this->arguments[$index] = $argument;
Chris@0 210
Chris@0 211 return $this;
Chris@0 212 }
Chris@0 213
Chris@0 214 /**
Chris@0 215 * Gets the arguments to pass to the service constructor/factory method.
Chris@0 216 *
Chris@0 217 * @return array The array of arguments
Chris@0 218 */
Chris@0 219 public function getArguments()
Chris@0 220 {
Chris@0 221 return $this->arguments;
Chris@0 222 }
Chris@0 223
Chris@0 224 /**
Chris@0 225 * Gets an argument to pass to the service constructor/factory method.
Chris@0 226 *
Chris@0 227 * @param int $index
Chris@0 228 *
Chris@0 229 * @return mixed The argument value
Chris@0 230 *
Chris@0 231 * @throws OutOfBoundsException When the argument does not exist
Chris@0 232 */
Chris@0 233 public function getArgument($index)
Chris@0 234 {
Chris@0 235 if ($index < 0 || $index > count($this->arguments) - 1) {
Chris@0 236 throw new OutOfBoundsException(sprintf('The index "%d" is not in the range [0, %d].', $index, count($this->arguments) - 1));
Chris@0 237 }
Chris@0 238
Chris@0 239 return $this->arguments[$index];
Chris@0 240 }
Chris@0 241
Chris@0 242 /**
Chris@0 243 * Sets the methods to call after service initialization.
Chris@0 244 *
Chris@0 245 * @param array $calls An array of method calls
Chris@0 246 *
Chris@0 247 * @return $this
Chris@0 248 */
Chris@0 249 public function setMethodCalls(array $calls = array())
Chris@0 250 {
Chris@0 251 $this->calls = array();
Chris@0 252 foreach ($calls as $call) {
Chris@0 253 $this->addMethodCall($call[0], $call[1]);
Chris@0 254 }
Chris@0 255
Chris@0 256 return $this;
Chris@0 257 }
Chris@0 258
Chris@0 259 /**
Chris@0 260 * Adds a method to call after service initialization.
Chris@0 261 *
Chris@0 262 * @param string $method The method name to call
Chris@0 263 * @param array $arguments An array of arguments to pass to the method call
Chris@0 264 *
Chris@0 265 * @return $this
Chris@0 266 *
Chris@0 267 * @throws InvalidArgumentException on empty $method param
Chris@0 268 */
Chris@0 269 public function addMethodCall($method, array $arguments = array())
Chris@0 270 {
Chris@0 271 if (empty($method)) {
Chris@0 272 throw new InvalidArgumentException('Method name cannot be empty.');
Chris@0 273 }
Chris@0 274 $this->calls[] = array($method, $arguments);
Chris@0 275
Chris@0 276 return $this;
Chris@0 277 }
Chris@0 278
Chris@0 279 /**
Chris@0 280 * Removes a method to call after service initialization.
Chris@0 281 *
Chris@0 282 * @param string $method The method name to remove
Chris@0 283 *
Chris@0 284 * @return $this
Chris@0 285 */
Chris@0 286 public function removeMethodCall($method)
Chris@0 287 {
Chris@0 288 foreach ($this->calls as $i => $call) {
Chris@0 289 if ($call[0] === $method) {
Chris@0 290 unset($this->calls[$i]);
Chris@0 291 break;
Chris@0 292 }
Chris@0 293 }
Chris@0 294
Chris@0 295 return $this;
Chris@0 296 }
Chris@0 297
Chris@0 298 /**
Chris@0 299 * Check if the current definition has a given method to call after service initialization.
Chris@0 300 *
Chris@0 301 * @param string $method The method name to search for
Chris@0 302 *
Chris@0 303 * @return bool
Chris@0 304 */
Chris@0 305 public function hasMethodCall($method)
Chris@0 306 {
Chris@0 307 foreach ($this->calls as $call) {
Chris@0 308 if ($call[0] === $method) {
Chris@0 309 return true;
Chris@0 310 }
Chris@0 311 }
Chris@0 312
Chris@0 313 return false;
Chris@0 314 }
Chris@0 315
Chris@0 316 /**
Chris@0 317 * Gets the methods to call after service initialization.
Chris@0 318 *
Chris@0 319 * @return array An array of method calls
Chris@0 320 */
Chris@0 321 public function getMethodCalls()
Chris@0 322 {
Chris@0 323 return $this->calls;
Chris@0 324 }
Chris@0 325
Chris@0 326 /**
Chris@0 327 * Sets tags for this definition.
Chris@0 328 *
Chris@0 329 * @param array $tags
Chris@0 330 *
Chris@0 331 * @return $this
Chris@0 332 */
Chris@0 333 public function setTags(array $tags)
Chris@0 334 {
Chris@0 335 $this->tags = $tags;
Chris@0 336
Chris@0 337 return $this;
Chris@0 338 }
Chris@0 339
Chris@0 340 /**
Chris@0 341 * Returns all tags.
Chris@0 342 *
Chris@0 343 * @return array An array of tags
Chris@0 344 */
Chris@0 345 public function getTags()
Chris@0 346 {
Chris@0 347 return $this->tags;
Chris@0 348 }
Chris@0 349
Chris@0 350 /**
Chris@0 351 * Gets a tag by name.
Chris@0 352 *
Chris@0 353 * @param string $name The tag name
Chris@0 354 *
Chris@0 355 * @return array An array of attributes
Chris@0 356 */
Chris@0 357 public function getTag($name)
Chris@0 358 {
Chris@0 359 return isset($this->tags[$name]) ? $this->tags[$name] : array();
Chris@0 360 }
Chris@0 361
Chris@0 362 /**
Chris@0 363 * Adds a tag for this definition.
Chris@0 364 *
Chris@0 365 * @param string $name The tag name
Chris@0 366 * @param array $attributes An array of attributes
Chris@0 367 *
Chris@0 368 * @return $this
Chris@0 369 */
Chris@0 370 public function addTag($name, array $attributes = array())
Chris@0 371 {
Chris@0 372 $this->tags[$name][] = $attributes;
Chris@0 373
Chris@0 374 return $this;
Chris@0 375 }
Chris@0 376
Chris@0 377 /**
Chris@0 378 * Whether this definition has a tag with the given name.
Chris@0 379 *
Chris@0 380 * @param string $name
Chris@0 381 *
Chris@0 382 * @return bool
Chris@0 383 */
Chris@0 384 public function hasTag($name)
Chris@0 385 {
Chris@0 386 return isset($this->tags[$name]);
Chris@0 387 }
Chris@0 388
Chris@0 389 /**
Chris@0 390 * Clears all tags for a given name.
Chris@0 391 *
Chris@0 392 * @param string $name The tag name
Chris@0 393 *
Chris@0 394 * @return $this
Chris@0 395 */
Chris@0 396 public function clearTag($name)
Chris@0 397 {
Chris@0 398 unset($this->tags[$name]);
Chris@0 399
Chris@0 400 return $this;
Chris@0 401 }
Chris@0 402
Chris@0 403 /**
Chris@0 404 * Clears the tags for this definition.
Chris@0 405 *
Chris@0 406 * @return $this
Chris@0 407 */
Chris@0 408 public function clearTags()
Chris@0 409 {
Chris@0 410 $this->tags = array();
Chris@0 411
Chris@0 412 return $this;
Chris@0 413 }
Chris@0 414
Chris@0 415 /**
Chris@0 416 * Sets a file to require before creating the service.
Chris@0 417 *
Chris@0 418 * @param string $file A full pathname to include
Chris@0 419 *
Chris@0 420 * @return $this
Chris@0 421 */
Chris@0 422 public function setFile($file)
Chris@0 423 {
Chris@0 424 $this->file = $file;
Chris@0 425
Chris@0 426 return $this;
Chris@0 427 }
Chris@0 428
Chris@0 429 /**
Chris@0 430 * Gets the file to require before creating the service.
Chris@0 431 *
Chris@0 432 * @return string|null The full pathname to include
Chris@0 433 */
Chris@0 434 public function getFile()
Chris@0 435 {
Chris@0 436 return $this->file;
Chris@0 437 }
Chris@0 438
Chris@0 439 /**
Chris@0 440 * Sets if the service must be shared or not.
Chris@0 441 *
Chris@0 442 * @param bool $shared Whether the service must be shared or not
Chris@0 443 *
Chris@0 444 * @return $this
Chris@0 445 */
Chris@0 446 public function setShared($shared)
Chris@0 447 {
Chris@0 448 $this->shared = (bool) $shared;
Chris@0 449
Chris@0 450 return $this;
Chris@0 451 }
Chris@0 452
Chris@0 453 /**
Chris@0 454 * Whether this service is shared.
Chris@0 455 *
Chris@0 456 * @return bool
Chris@0 457 */
Chris@0 458 public function isShared()
Chris@0 459 {
Chris@0 460 return $this->shared;
Chris@0 461 }
Chris@0 462
Chris@0 463 /**
Chris@0 464 * Sets the visibility of this service.
Chris@0 465 *
Chris@0 466 * @param bool $boolean
Chris@0 467 *
Chris@0 468 * @return $this
Chris@0 469 */
Chris@0 470 public function setPublic($boolean)
Chris@0 471 {
Chris@0 472 $this->public = (bool) $boolean;
Chris@0 473
Chris@0 474 return $this;
Chris@0 475 }
Chris@0 476
Chris@0 477 /**
Chris@0 478 * Whether this service is public facing.
Chris@0 479 *
Chris@0 480 * @return bool
Chris@0 481 */
Chris@0 482 public function isPublic()
Chris@0 483 {
Chris@0 484 return $this->public;
Chris@0 485 }
Chris@0 486
Chris@0 487 /**
Chris@0 488 * Sets the lazy flag of this service.
Chris@0 489 *
Chris@0 490 * @param bool $lazy
Chris@0 491 *
Chris@0 492 * @return $this
Chris@0 493 */
Chris@0 494 public function setLazy($lazy)
Chris@0 495 {
Chris@0 496 $this->lazy = (bool) $lazy;
Chris@0 497
Chris@0 498 return $this;
Chris@0 499 }
Chris@0 500
Chris@0 501 /**
Chris@0 502 * Whether this service is lazy.
Chris@0 503 *
Chris@0 504 * @return bool
Chris@0 505 */
Chris@0 506 public function isLazy()
Chris@0 507 {
Chris@0 508 return $this->lazy;
Chris@0 509 }
Chris@0 510
Chris@0 511 /**
Chris@0 512 * Sets whether this definition is synthetic, that is not constructed by the
Chris@0 513 * container, but dynamically injected.
Chris@0 514 *
Chris@0 515 * @param bool $boolean
Chris@0 516 *
Chris@0 517 * @return $this
Chris@0 518 */
Chris@0 519 public function setSynthetic($boolean)
Chris@0 520 {
Chris@0 521 $this->synthetic = (bool) $boolean;
Chris@0 522
Chris@0 523 return $this;
Chris@0 524 }
Chris@0 525
Chris@0 526 /**
Chris@0 527 * Whether this definition is synthetic, that is not constructed by the
Chris@0 528 * container, but dynamically injected.
Chris@0 529 *
Chris@0 530 * @return bool
Chris@0 531 */
Chris@0 532 public function isSynthetic()
Chris@0 533 {
Chris@0 534 return $this->synthetic;
Chris@0 535 }
Chris@0 536
Chris@0 537 /**
Chris@0 538 * Whether this definition is abstract, that means it merely serves as a
Chris@0 539 * template for other definitions.
Chris@0 540 *
Chris@0 541 * @param bool $boolean
Chris@0 542 *
Chris@0 543 * @return $this
Chris@0 544 */
Chris@0 545 public function setAbstract($boolean)
Chris@0 546 {
Chris@0 547 $this->abstract = (bool) $boolean;
Chris@0 548
Chris@0 549 return $this;
Chris@0 550 }
Chris@0 551
Chris@0 552 /**
Chris@0 553 * Whether this definition is abstract, that means it merely serves as a
Chris@0 554 * template for other definitions.
Chris@0 555 *
Chris@0 556 * @return bool
Chris@0 557 */
Chris@0 558 public function isAbstract()
Chris@0 559 {
Chris@0 560 return $this->abstract;
Chris@0 561 }
Chris@0 562
Chris@0 563 /**
Chris@0 564 * Whether this definition is deprecated, that means it should not be called
Chris@0 565 * anymore.
Chris@0 566 *
Chris@0 567 * @param bool $status
Chris@0 568 * @param string $template Template message to use if the definition is deprecated
Chris@0 569 *
Chris@0 570 * @return $this
Chris@0 571 *
Chris@0 572 * @throws InvalidArgumentException When the message template is invalid.
Chris@0 573 */
Chris@0 574 public function setDeprecated($status = true, $template = null)
Chris@0 575 {
Chris@0 576 if (null !== $template) {
Chris@0 577 if (preg_match('#[\r\n]|\*/#', $template)) {
Chris@0 578 throw new InvalidArgumentException('Invalid characters found in deprecation template.');
Chris@0 579 }
Chris@0 580
Chris@0 581 if (false === strpos($template, '%service_id%')) {
Chris@0 582 throw new InvalidArgumentException('The deprecation template must contain the "%service_id%" placeholder.');
Chris@0 583 }
Chris@0 584
Chris@0 585 $this->deprecationTemplate = $template;
Chris@0 586 }
Chris@0 587
Chris@0 588 $this->deprecated = (bool) $status;
Chris@0 589
Chris@0 590 return $this;
Chris@0 591 }
Chris@0 592
Chris@0 593 /**
Chris@0 594 * Whether this definition is deprecated, that means it should not be called
Chris@0 595 * anymore.
Chris@0 596 *
Chris@0 597 * @return bool
Chris@0 598 */
Chris@0 599 public function isDeprecated()
Chris@0 600 {
Chris@0 601 return $this->deprecated;
Chris@0 602 }
Chris@0 603
Chris@0 604 /**
Chris@0 605 * Message to use if this definition is deprecated.
Chris@0 606 *
Chris@0 607 * @param string $id Service id relying on this definition
Chris@0 608 *
Chris@0 609 * @return string
Chris@0 610 */
Chris@0 611 public function getDeprecationMessage($id)
Chris@0 612 {
Chris@0 613 return str_replace('%service_id%', $id, $this->deprecationTemplate);
Chris@0 614 }
Chris@0 615
Chris@0 616 /**
Chris@0 617 * Sets a configurator to call after the service is fully initialized.
Chris@0 618 *
Chris@0 619 * @param string|array $configurator A PHP callable
Chris@0 620 *
Chris@0 621 * @return $this
Chris@0 622 */
Chris@0 623 public function setConfigurator($configurator)
Chris@0 624 {
Chris@0 625 if (is_string($configurator) && strpos($configurator, '::') !== false) {
Chris@0 626 $configurator = explode('::', $configurator, 2);
Chris@0 627 }
Chris@0 628
Chris@0 629 $this->configurator = $configurator;
Chris@0 630
Chris@0 631 return $this;
Chris@0 632 }
Chris@0 633
Chris@0 634 /**
Chris@0 635 * Gets the configurator to call after the service is fully initialized.
Chris@0 636 *
Chris@0 637 * @return callable|null The PHP callable to call
Chris@0 638 */
Chris@0 639 public function getConfigurator()
Chris@0 640 {
Chris@0 641 return $this->configurator;
Chris@0 642 }
Chris@0 643
Chris@0 644 /**
Chris@0 645 * Sets types that will default to this definition.
Chris@0 646 *
Chris@0 647 * @param string[] $types
Chris@0 648 *
Chris@0 649 * @return $this
Chris@0 650 */
Chris@0 651 public function setAutowiringTypes(array $types)
Chris@0 652 {
Chris@0 653 $this->autowiringTypes = array();
Chris@0 654
Chris@0 655 foreach ($types as $type) {
Chris@0 656 $this->autowiringTypes[$type] = true;
Chris@0 657 }
Chris@0 658
Chris@0 659 return $this;
Chris@0 660 }
Chris@0 661
Chris@0 662 /**
Chris@0 663 * Is the definition autowired?
Chris@0 664 *
Chris@0 665 * @return bool
Chris@0 666 */
Chris@0 667 public function isAutowired()
Chris@0 668 {
Chris@0 669 return $this->autowired;
Chris@0 670 }
Chris@0 671
Chris@0 672 /**
Chris@0 673 * Sets autowired.
Chris@0 674 *
Chris@0 675 * @param bool $autowired
Chris@0 676 *
Chris@0 677 * @return $this
Chris@0 678 */
Chris@0 679 public function setAutowired($autowired)
Chris@0 680 {
Chris@0 681 $this->autowired = $autowired;
Chris@0 682
Chris@0 683 return $this;
Chris@0 684 }
Chris@0 685
Chris@0 686 /**
Chris@0 687 * Gets autowiring types that will default to this definition.
Chris@0 688 *
Chris@0 689 * @return string[]
Chris@0 690 */
Chris@0 691 public function getAutowiringTypes()
Chris@0 692 {
Chris@0 693 return array_keys($this->autowiringTypes);
Chris@0 694 }
Chris@0 695
Chris@0 696 /**
Chris@0 697 * Adds a type that will default to this definition.
Chris@0 698 *
Chris@0 699 * @param string $type
Chris@0 700 *
Chris@0 701 * @return $this
Chris@0 702 */
Chris@0 703 public function addAutowiringType($type)
Chris@0 704 {
Chris@0 705 $this->autowiringTypes[$type] = true;
Chris@0 706
Chris@0 707 return $this;
Chris@0 708 }
Chris@0 709
Chris@0 710 /**
Chris@0 711 * Removes a type.
Chris@0 712 *
Chris@0 713 * @param string $type
Chris@0 714 *
Chris@0 715 * @return $this
Chris@0 716 */
Chris@0 717 public function removeAutowiringType($type)
Chris@0 718 {
Chris@0 719 unset($this->autowiringTypes[$type]);
Chris@0 720
Chris@0 721 return $this;
Chris@0 722 }
Chris@0 723
Chris@0 724 /**
Chris@0 725 * Will this definition default for the given type?
Chris@0 726 *
Chris@0 727 * @param string $type
Chris@0 728 *
Chris@0 729 * @return bool
Chris@0 730 */
Chris@0 731 public function hasAutowiringType($type)
Chris@0 732 {
Chris@0 733 return isset($this->autowiringTypes[$type]);
Chris@0 734 }
Chris@0 735 }