2015-11-14
@override
@see \Df\Config\Source::map()
@used-by \Df\Config\Source::toOptionArray()
@return array(string => string)
495354
protected function map() {
		/** @var string|null $sample */
		$sample = $this->f('dfSample');
		/** @var string[] $values */
		$values = [self::_DEFAULT, self::$UCFIRST, self::$UCWORDS, self::$UPPERCASE, self::$LOWERCASE];
		/** @var string[] $labels */
		$labels = [
			'As Is'
			, 'Uppercase first letter'
			, 'Uppercase Each Word\'s First Letter'
			,'UPPERCASE'
			,'lowercase'
		];
		return array_combine(
			$values
			,!$sample
			? $labels
			: array_map(function($value, $label) use($sample) {
				return sprintf('%s (%s)', self::apply($sample, $value), $label);
			}, $values, $labels)
			//: df_map([__CLASS__, 'apply'], $keys, [], $sample)
		);
	}
549760
protected function getMapRateOptions() {
    $map = [];

    $cid = __METHOD__;
    if ($cache = $this->cache->get($cid)) {
      return $cache->data;
    }

    $domain = $this->getUrlFromOpenyProgramsSearchSettings('base_url');

    // Here we'll iterate over each program and scrape data for each school.
    // We should be careful in order not to make a high load on Daxko.
    $programs = $this->getAllChildCarePrograms();
    foreach ($programs as $program) {
      // Get a list of schools for particular program.
      $schools = $this->scrapeDaxkoSchoolsByProgram($program->id);

      // @todo Check whether we were scraping correct page (with schools).
      $school_pages = $schools->each(function ($school) {
        $href = $school->attr('href');
        return [
          'url' => $href,
          'id' => $this->getQueryParam('location_id', $href),
        ];
      });

      // Scrape each school page to get the rates url.
      foreach ($school_pages as $school_page) {
        $url = $domain . $school_page['url'];
        $source = $this->getDaxkoPageSource($url);
        $this->crawler->clear();
        $this->crawler->addHtmlContent($source);
        $rate_list = $this->crawler->filter('#session-list-table tr.childcare-rate');

        // Scrape each rate item.
        $rate_data = $rate_list->each(function ($rate_data_item) {
          // Get context ID && session name.
          $link = $rate_data_item->filter('a.session-name');
          return [
            'context_id' => $this->getQueryParam('context_id', $link->attr('href')),
            'name' => $link->text(),
            'registration_url' => $link->attr('href'),
          ];
        });

        // Fill in map dada.
        if (!isset($map[$school_page['id']][$program->id])) {
          $map[$school_page['id']][$program->id] = [];
        }

        foreach ($rate_data as $rate_data_item) {
          $map[$school_page['id']][$program->id][$rate_data_item['context_id']] = $rate_data_item;
        }
      }
    }

    $this->cache->set($cid, $map);
    return $map;
  }
1156837
public function getMapTables()
    {
        $tables = [];

        if (is_array($GLOBALS['con4gis']['maps']['sourcetable']))
        {
            foreach ($GLOBALS['con4gis']['maps']['sourcetable'] as $key=>$sourcetable) {
                $tables[$key] = $GLOBALS['TL_LANG']['c4g_maps']['sourcetable'][$key]['name'];
            }
        }

        return $tables;
    }
14638
public function getOptionsAsArray()
    {
        $options      = $this->getOptions();
        $optionsArray = [];
        foreach ($options as $option) {
            $optionsArray[$option->getValue()] = $option->getNodeValue();
        }
        return $optionsArray;
    }
521653
public static function map($options = null)
	{
		if (empty(self::$_google)) {
			self::$_google = new GoogleMapAPI();
			self::$_google->_minify_js = false;

			// Apply options
			if (is_array($options)) {
				foreach ($options as $key => $value) {
					self::$_google->$key = $value;
				}
			};
		}

		return self::$_google;
	}
1330405
public function getExtendedConfig() {
        $config = array();
        foreach ($this->getOption(self::OPTION_CONFIG_SOURCES) as $key => $source) {
            $config[$key] = $source->getConfig();
        }
        return $config;
    }
491477
public function toOptionArray()
    {
        $defaultOptions = $this->defaultOptions();
        $productCondition = $this->productFactory;
        $productAttributes = $productCondition->loadAttributeOptions()
            ->getAttributeOption();
        $pAttributes = [];
        foreach ($productAttributes as $code => $label) {
            if (strpos($code, 'quote_item_') === false) {
                $pAttributes[$code] = $label;
            }
        }
        $options = array_merge($defaultOptions, $pAttributes);

        return $options;
    }
44294
public function optgroups($options = []) {
		if (empty($this->optgroups_map)) {
			return $this->options($options);
		} else {
			$options['options_map_addition'][$this->optgroups_map['column']] = $this->optgroups_map['column'];
			return \Object\Data\Common::optgroups($this->options($options), $this->optgroups_map, ['name' => 'name']);
		}
	}
380578
public static function optgroups($data, $optgroups_map, $options_map) {
		$column = $optgroups_map['column'];
		if (!empty($optgroups_map['model'])) {
			$model = $optgroups_map['model'];
			$object = new $model();
			$model_names = $object->options();
		} else {
			$model_names = [];
		}
		$result = [];
		foreach ($data as $k => $v) {
			if (!isset($result[$v[$column]])) {
				$result[$v[$column]] = [
					'name' => $model_names[$v[$column]]['name'] ?? $v[$column],
					'options' => []
				];
			}
			$result[$v[$column]]['options'][$k] = $v;
		}
		// sorting and remapping
		foreach ($result as $k => $v) {
			$result[$k]['options'] = self::options($result[$k]['options'], $options_map);
		}
		array_key_sort($result, ['name' => SORT_ASC]);
		return $result;
	}
832762
public function makeSchema(): array
    {
        return [
            Filter::SH_MAP       => $this->buildMap($this->entity),
            Filter::SH_VALIDATES => $this->entity->getProperty('validates', true) ?? [],
            Filter::SH_SECURED   => $this->entity->getSecured(),
            Filter::SH_FILLABLE  => $this->entity->getFillable(),
            Filter::SH_MUTATORS  => $this->entity->getMutators(),
        ];
    }
416125
public function toOptionArray()
    {
        $fields[] = [
            'label' => __('---- Default Option ----'),
            'value' => '0',
        ];
        $apiEnabled = $this->helper->isEnabled($this->helper->getWebsite());
        //get datafields options
        if ($apiEnabled) {
            $datafields = $this->getDataFields();

            //set the api error message for the first option
            if (isset($datafields->message)) {
                //message
                $fields[] = [
                    'value' => 0,
                    'label' => $datafields->message,
                ];
            } else {
                //loop for all datafields option
                foreach ($datafields as $datafield) {
                    if (isset($datafield->name)
                        && $datafield->visibility == 'Public'
                    ) {
                        $fields[] = [
                            'value' => $datafield->name,
                            'label' => $datafield->name,
                        ];
                    }
                }
            }
        }

        return $fields;
    }
727810
public function toArray(): array
    {
        $config = [];

        if ($this->config->has('key')) {
            $config['key'] = $this->getKey();
        } else {
            $config['key'] = Key::generate($this->getKey(), 'field');
        }

        if ($this->config->has('conditional_logic')) {
            $config['conditional_logic'] = $this->getConditionalLogic();
        }

        if ($this->config->has('layouts')) {
            $config['layouts'] = $this->getLayouts();
        }

        if ($this->config->has('sub_fields')) {
            $config['sub_fields'] = $this->getSubFields();
        }

        return array_merge($this->config->toArray(), $config);
    }
1122810
public function toStrictArray() {
        $colsArray = $this->getColArray();
        
        $rowsArray = $this->rows;
        
        array_walk($rowsArray, function (&$item, $key, $cols) {
            $item = array('c' => $item->toMatchingArray($cols));
        }, $this->cols);

        return self::getFilteredArray($colsArray, $rowsArray, $this->p);
        
    }
1273202
protected function mapContrib()
    {
        $root    = $this->finder->getSourceRoot();
        $pathMap = $this->config->getPaths();
        $paths   = [];

        foreach ($this->getPackages() as $package) {

            if ($drupalType = $this->getDrupalType($package)) {
                $sourcePath = $this->getInstallPath($package);

                if (strpos($sourcePath, $root) !== false) {
                    $sourcePath = $this->getFS()->makePathRelative(
                        $sourcePath,
                        $root
                    );
                }

                $mapRef =& $paths[$drupalType][rtrim($sourcePath, DIRECTORY_SEPARATOR)];

                if (in_array($drupalType, ['module', 'theme'])) {
                    $mapRef = sprintf(
                        $pathMap[$drupalType] . DIRECTORY_SEPARATOR . '%s',
                        'contrib',
                        basename($package->getPrettyName())
                    );
                }

                else {
                    $mapRef = $pathMap[$drupalType];
                }
            }
        }

        return array_intersect_key($paths, $pathMap);
    }
313710
public function toArray()
    {
        $array = array();
        $data = $this->data;

        foreach ($data as $key => $value) {
            if ($value instanceof Config) {
                $array[$key] = $value->toArray();
            } else {
                $array[$key] = $value;
            }
        }

        return $array;
    }
401083
public function mapped($options)
    {
        if (is_array($options)) {
            $use = $options['use'];
            unset($options['use']);
        } else {
            $use = $options;
            $options = [];
        }

        if (!isset($this->_maps[$use])) {
            return 'string';
        }

        foreach ($this->_maps[$use] as $type => $value) {
            if (!array_diff_assoc($value, $options)) {
                return $type;
            }
        }
        return 'string';
    }
1246043
public function toMappedArray()
    {
        $values = $this->toArray();
        $mappedValues = [];
        foreach ($values as $key => $value) {
            $mappedValues[$key] = $this->readMapped($key);
        }

        return $mappedValues;
    }