variables = $this->configuration['variables']; } /** * {@inheritdoc} */ protected function initializeIterator() { return new \ArrayIterator([$this->values()]); } /** * Return the values of the variables specified in the plugin configuration. * * @return array * An associative array where the keys are the variables specified in the * plugin configuration and the values are the values found in the source. * Only those values are returned that are actually in the database. */ protected function values() { // Create an ID field so we can record migration in the map table. // Arbitrarily, use the first variable name. $values['id'] = reset($this->variables); return $values + array_map('unserialize', $this->prepareQuery()->execute()->fetchAllKeyed()); } /** * {@inheritdoc} */ public function count() { return intval($this->query()->countQuery()->execute()->fetchField() > 0); } /** * {@inheritdoc} */ public function fields() { return array_combine($this->variables, $this->variables); } /** * {@inheritdoc} */ public function query() { return $this->getDatabase() ->select('variable', 'v') ->fields('v', ['name', 'value']) ->condition('name', $this->variables, 'IN'); } /** * {@inheritdoc} */ public function getIds() { $ids['id']['type'] = 'string'; return $ids; } }