1 | <?php |
||
31 | class UpdateCommand extends AbstractCommand |
||
32 | { |
||
33 | private $timeout; |
||
34 | |||
35 | protected function configure() |
||
36 | { |
||
37 | $this |
||
38 | ->setName('odm:schema:update') |
||
39 | ->addOption('class', 'c', InputOption::VALUE_OPTIONAL, 'Document class to process (default: all classes)') |
||
40 | ->addOption('timeout', 't', InputOption::VALUE_OPTIONAL, 'Timeout (ms) for acknowledged index creation') |
||
41 | ->setDescription('Update indexes for your documents') |
||
42 | ; |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * @param InputInterface $input |
||
47 | * @param OutputInterface $output |
||
48 | * @return int|null|void |
||
49 | */ |
||
50 | protected function execute(InputInterface $input, OutputInterface $output) |
||
51 | { |
||
52 | $class = $input->getOption('class'); |
||
53 | |||
54 | $timeout = $input->getOption('timeout'); |
||
55 | $this->timeout = isset($timeout) ? (int) $timeout : null; |
||
56 | |||
57 | $sm = $this->getSchemaManager(); |
||
58 | $isErrored = false; |
||
59 | |||
60 | try { |
||
61 | if (isset($class)) { |
||
62 | $this->processDocumentIndex($sm, $class); |
||
63 | $output->writeln(sprintf('Updated <comment>index(es)</comment> for <info>%s</info>', $class)); |
||
64 | } else { |
||
65 | $this->processIndex($sm); |
||
66 | $output->writeln('Updated <comment>indexes</comment> for <info>all classes</info>'); |
||
67 | } |
||
68 | } catch (\Exception $e) { |
||
69 | $output->writeln('<error>' . $e->getMessage() . '</error>'); |
||
70 | $isErrored = true; |
||
71 | } |
||
72 | |||
73 | return ($isErrored) ? 255 : 0; |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * @param SchemaManager $sm |
||
78 | * @param object $document |
||
79 | */ |
||
80 | protected function processDocumentIndex(SchemaManager $sm, $document) |
||
84 | |||
85 | /** |
||
86 | * @param SchemaManager $sm |
||
87 | */ |
||
88 | protected function processIndex(SchemaManager $sm) |
||
92 | |||
93 | /** |
||
94 | * @param SchemaManager $sm |
||
95 | * @param object $document |
||
96 | * @throws \BadMethodCallException |
||
97 | */ |
||
98 | protected function processDocumentCollection(SchemaManager $sm, $document) |
||
102 | |||
103 | /** |
||
104 | * @param SchemaManager $sm |
||
105 | * @throws \BadMethodCallException |
||
106 | */ |
||
107 | protected function processCollection(SchemaManager $sm) |
||
111 | |||
112 | /** |
||
113 | * @param SchemaManager $sm |
||
114 | * @param object $document |
||
115 | * @throws \BadMethodCallException |
||
116 | */ |
||
117 | protected function processDocumentDb(SchemaManager $sm, $document) |
||
121 | |||
122 | /** |
||
123 | * @param SchemaManager $sm |
||
124 | * @throws \BadMethodCallException |
||
125 | */ |
||
126 | protected function processDb(SchemaManager $sm) |
||
130 | } |
||
131 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: