/** * @return array */ public function getBreadcrumbList() { $crumbs = []; $tree = $this->tree; // Work through our parts and see if there is a translation for them foreach (explode('/', $this->uri) as $crumb) { // do a standard lookup first $lang = Arr::get($tree, $crumb, null); // if it's an array, it's a folder, so fetch it's title if (is_array($lang)) { $crumbs[$crumb] = Arr::get($lang, '__title', $crumb); $tree = $lang; } elseif ($lang) { $crumbs[$crumb] = $lang; } else { // start with an untranslated default $crumbs[$crumb] = $crumb; // loop over the translations to find a match foreach ($tree as $name => $lang) { // do we need preprocessing of the filename found? if ($this->preProcessor instanceof Closure) { $lookup = $this->preProcessor->__invoke($name); } else { $lookup = $name; } if ($lookup == $crumb) { $crumbs[$crumb] = $lang; break; } } } } return $crumbs; }
public function html() { // Pull Meter Details if ($meter = Arr::get($this->data, 'Meter')) { foreach ($meter as $key => $value) { $meterDetails[] = '<div class="aeon ' . strtolower($key) . '">' . $value . '</div>'; } $return[] = implode($meterDetails, PHP_EOL) . PHP_EOL; } // Check for key change if ($bss = Arr::get($this->data, 'BSSTTokens.BSSTToken')) { foreach ($bss as $token) { $bssTokens[] = '<div class="aeon bss ' . strtolower($key) . '">' . $value . '</div>'; } $return[] = implode($bssTokens, PHP_EOL) . PHP_EOL; } // Other info $otherInfo['utility'] = Arr::get($this->data, 'Utility'); $otherInfo['custMsg'] = Arr::get($this->data, 'CustMsg'); $otherInfo['vatNo'] = Arr::get($this->data, 'VatNo'); $otherInfo['transRef'] = Arr::get($this->data, 'TransRef'); $otherInfo['tariffName'] = Arr::get($this->data, 'TariffName'); $otherInfo['reference'] = Arr::get($this->data, 'Reference'); $otherInfo['reprint'] = Arr::get($this->data, 'Reprint'); foreach (array_filter($otherInfo) as $key => $value) { $info[] = '<div class="aeon info ' . strtolower($key) . '">' . $value . '</div>'; } $return[] = implode($info, PHP_EOL) . PHP_EOL; // Return all; return implode($return); }
/** * Object constructor * * @param string * @param array */ protected function __construct($name, array $config = array()) { // Grab the form attributes $formAttributes = Arr::get($config, 'form_attributes', array()); $this->form = new Form(); $this->form->setAttributes($formAttributes); $this->form->setName($name); }
/** * Populates the fields using the array passed. * * @param array $data The data to use for population. * * @return \Fuel\Fieldset\InputContainer * * @since 2.0 */ public function populate($data) { // Loop through all the elements assigned and attempt to assign a value to them. foreach ($this->getContents() as $item) { if ($item instanceof InputContainer) { // This is another Fieldset or Form so needs to be populated too $item->populate($data); } else { // Convert the name to a dot notation for better searching $key = $this->inputNameToKey($item->getName()); $value = Arr::get($data, $key); if (!is_null($value)) { $item->setValue($value); } } } return $this; }
/** * Gets a value from the Input config. * * @param string|null $key Dot notated key or null for all * * @return string * * @since 2.0 */ public function config($key = null) { if (is_null($key)) { return $this->config; } return Arr::get($this->config, $key); }
/** * @covers Fuel\Common\Arr::get * @expectedException \InvalidArgumentException * @group Common */ public function testGetException() { Arr::get('no-array', 'key'); }
/** * @param string $dir * * @return array */ protected function readDir($dir, $order, $translations) { // check if we need to split entries $splitEntries = $order & static::SORT_FILES_FIRST || $order & static::SORT_FOLDERS_FIRST; // temporary storage for results $files = []; $folders = []; if ($title = Arr::get($translations, '__title')) { if ($splitEntries) { $folders['__title'] = $title; } else { $files['__title'] = $title; } } // loop over the given folder $handle = opendir($dir); while (false !== ($entry = readdir($handle))) { // skip directory entries if ($entry == '..' || $entry == '.') { continue; } // construct the FQFN $filename = $dir . DIRECTORY_SEPARATOR . $entry; // if it's a file... if (is_file($filename)) { // do we need preprocessing of the filename found? if ($this->preProcessor instanceof Closure) { $file = $this->preProcessor->__invoke($entry); } else { $file = $entry; } // translate the filename (with or without extension) if needed $files[$entry] = Arr::get($translations, $file, $entry); } elseif (is_dir($filename)) { // recurse to add the folder contents $result = $this->readDir($filename, $order, Arr::get($translations, $entry, [])); // store the result in the correct result array if ($splitEntries) { $folders[$entry] = $result; } else { $files[$entry] = $result; } } } // do we need to other by translation sequence? $translateOrder = []; if ($order & static::SORT_TRANSLATIONS) { foreach ($translations as $name => $unused) { if ($name !== '__title') { if ($order & static::SORT_FOLDERS_FIRST) { foreach ($folders as $folder => $entry) { if ($name === $folder) { $translateOrder[$folder] = $entry; unset($folders[$folder]); break; } } } foreach ($files as $file => $entry) { if ($name === $file or strpos($file, $name . '.') === 0) { $translateOrder[$file] = $entry; unset($files[$file]); break; } } } } } // sort the result if needed if ($order & static::SORT_ASCENDING) { ksort($files); ksort($folders); } elseif ($order & static::SORT_DESCENDING) { krsort($files); krsort($folders); } // and return in the order requested if ($order & static::SORT_FOLDERS_FIRST) { return $translateOrder + $folders + $files; } return $translateOrder + $files + $folders; }
/** * @param string $key * @param null $default * * @return mixed * * @since 2.0 */ public function getMeta($key, $default = null) { return Arr::get($this->metaContainer, $key, $default); }
/** * @return bool true or false depending on the status of the input * * @since 2.0 */ public function isChecked() { return Arr::get($this->attributes, 'checked', false); }
/** * @param string $name * * @return ModelCollectionInterface|ModelInterface|null * * @since 2.0 */ protected function loadRelations($name) { // Does it need loading? if (!isset($this->populatedRelations[$name])) { // It does so grab the data $this->populatedRelations[$name] = $this->provider->getRelation($name)->getModels($this); } // Return the relation return Arr::get($this->populatedRelations, $name); }