| @@ 23-99 (lines=77) @@ | ||
| 20 | * | |
| 21 | * @author Beñat Espiña <[email protected]> | |
| 22 | */ | |
| 23 | abstract class CommandBuilder implements ApplicationBuilder | |
| 24 | { | |
| 25 | /** | |
| 26 | * Configuration array. | |
| 27 | * | |
| 28 | * @var array | |
| 29 | */ | |
| 30 | protected $configuration; | |
| 31 | ||
| 32 | /** | |
| 33 | * The container builder. | |
| 34 | * | |
| 35 | * @var ContainerBuilder | |
| 36 | */ | |
| 37 | protected $container; | |
| 38 | ||
| 39 | /** | |
| 40 | * The persistence driver. | |
| 41 | * | |
| 42 | * @var string | |
| 43 | */ | |
| 44 | protected $persistence; | |
| 45 | ||
| 46 | /** | |
| 47 | * Constructor. | |
| 48 | * | |
| 49 | * @param ContainerBuilder $container The container builder | |
| 50 | * @param string $persistence The persistence driver | |
| 51 | * @param array $configuration The configuration tree | |
| 52 | */ | |
| 53 | public function __construct(ContainerBuilder $container, $persistence, array $configuration = []) | |
| 54 |     { | |
| 55 | $this->container = $container; | |
| 56 | $this->persistence = $persistence; | |
| 57 | $this->configuration = $configuration; | |
| 58 | } | |
| 59 | ||
| 60 | /** | |
| 61 |      * {@inheritdoc} | |
| 62 | */ | |
| 63 | public function build($file) | |
| 64 |     { | |
| 65 | $this->register($file); | |
| 66 | ||
| 67 | $this->container->setAlias( | |
| 68 | $this->aliasDefinitionName($file), | |
| 69 | $this->definitionName($file) | |
| 70 | ); | |
| 71 | ||
| 72 | return $this->container; | |
| 73 | } | |
| 74 | ||
| 75 | /** | |
| 76 | * Gets the command definition name. | |
| 77 | * | |
| 78 | * @param string $file The file name | |
| 79 | * | |
| 80 | * @return string | |
| 81 | */ | |
| 82 | abstract protected function definitionName($file); | |
| 83 | ||
| 84 | /** | |
| 85 | * Gets the command definition name alias. | |
| 86 | * | |
| 87 | * @param string $file The file name | |
| 88 | * | |
| 89 | * @return string | |
| 90 | */ | |
| 91 | abstract protected function aliasDefinitionName($file); | |
| 92 | ||
| 93 | /** | |
| 94 | * Registers the command into container. | |
| 95 | * | |
| 96 | * @param string $file The file name | |
| 97 | */ | |
| 98 | abstract protected function register($file); | |
| 99 | } | |
| 100 | ||
| @@ 23-90 (lines=68) @@ | ||
| 20 | * | |
| 21 | * @author Beñat Espiña <[email protected]> | |
| 22 | */ | |
| 23 | abstract class QueryBuilder implements ApplicationBuilder | |
| 24 | { | |
| 25 | /** | |
| 26 | * Configuration array. | |
| 27 | * | |
| 28 | * @var array | |
| 29 | */ | |
| 30 | protected $configuration; | |
| 31 | ||
| 32 | /** | |
| 33 | * The container builder. | |
| 34 | * | |
| 35 | * @var ContainerBuilder | |
| 36 | */ | |
| 37 | protected $container; | |
| 38 | ||
| 39 | /** | |
| 40 | * Constructor. | |
| 41 | * | |
| 42 | * @param ContainerBuilder $container The container builder | |
| 43 | * @param array $configuration The configuration tree | |
| 44 | */ | |
| 45 | public function __construct(ContainerBuilder $container, array $configuration = []) | |
| 46 |     { | |
| 47 | $this->container = $container; | |
| 48 | $this->configuration = $configuration; | |
| 49 | } | |
| 50 | ||
| 51 | /** | |
| 52 |      * {@inheritdoc} | |
| 53 | */ | |
| 54 | public function build($file) | |
| 55 |     { | |
| 56 | $this->register($file); | |
| 57 | ||
| 58 | $this->container->setAlias( | |
| 59 | $this->aliasDefinitionName($file), | |
| 60 | $this->definitionName($file) | |
| 61 | ); | |
| 62 | ||
| 63 | return $this->container; | |
| 64 | } | |
| 65 | ||
| 66 | /** | |
| 67 | * Gets the query definition name. | |
| 68 | * | |
| 69 | * @param string $file The file name | |
| 70 | * | |
| 71 | * @return string | |
| 72 | */ | |
| 73 | abstract protected function definitionName($file); | |
| 74 | ||
| 75 | /** | |
| 76 | * Gets the query definition name alias. | |
| 77 | * | |
| 78 | * @param string $file The file name | |
| 79 | * | |
| 80 | * @return string | |
| 81 | */ | |
| 82 | abstract protected function aliasDefinitionName($file); | |
| 83 | ||
| 84 | /** | |
| 85 | * Registers the query into container. | |
| 86 | * | |
| 87 | * @param string $file The file name | |
| 88 | */ | |
| 89 | abstract protected function register($file); | |
| 90 | } | |
| 91 | ||