/** * @param integer $object_model_id * @param string $type * @return string */ public static function getSumPrice($object_model_id, $type) { $objects = static::find()->select('price')->where(['special_price_list_id' => ArrayHelper::map(SpecialPriceList::getModelsByKey($type), 'id', 'id'), 'object_model_id' => $object_model_id])->asArray()->all(); return array_reduce($objects, function ($result, $item) { return $result += $item['price']; }, 0); }
/** * @return Response * @throws \RuntimeException */ public function buildResponse() { if (!$this->isComplete) { throw new \RuntimeException('Response not complete yet'); } return array_reduce($this->records, function (Response $response, Record $record) { switch ($record->type) { case Record::BEGIN_REQUEST: case Record::ABORT_REQUEST: case Record::PARAMS: case Record::STDIN: case Record::DATA: case Record::GET_VALUES: throw new \RuntimeException('Cannot build a response from an request record'); break; case Record::STDOUT: $response->content .= $record->content; break; case Record::STDERR: $response->error .= $record->content; break; case Record::END_REQUEST: break; case Record::GET_VALUES_RESULT: break; case Record::UNKNOWN_TYPE: break; default: throw new \RuntimeException('Unknown package type received'); break; } return $response; }, new Response()); }
public function serve($cycle = null, $flags = 0) { $cycle = $cycle ? $cycle : Cycle::create(); $result = $this->dispatch($cycle->request()->getMethod(), $cycle->request()->getUri()->getPath(), $flags); if (!$result) { $w = $cycle(404, []); $w($cycle->request()->getUri()); return $this->emit($cycle); } $plugins = $result['plugins']; $cycle->setMountPoint($result['mountpoint']); $cycle->setPathParameters($result['parameters']); $runner = $result['handler']; if (!is_callable($runner)) { //build method annotation plugins $plugins = array_merge($runner->buildPlugins($result['annotationPlugins'] + $this->getAnnotationPlugins()), $plugins); $runner = $runner->getCallable(); } //build callable $callable = array_reduce(array_merge($plugins, $this->plugins), function ($carry, $item) { return $item($carry); }, $runner); $r = $callable($cycle); return $this->emit($cycle, $r); }
public function load($indexList = null, $column = false) { $sqlQuery = new SqlQuery(); $column = $column ? $column : $this->index; if (isset($indexList)) { $indexList = " WHERE " . $column . " IN (" . implode(',', $indexList) . ")" . implode(' AND ', $this->filters); } else { $indexList = array_reduce($this->filters, function ($prev, $next) { return $prev == "" ? " WHERE " . $next : $prev . " AND " . $next; }, ""); } if ($this->order) { $indexList .= ' ORDER BY `' . $this->orderColumn . '` ' . $this->orderDir; } if ($this->limit > -1) { $indexList .= ' LIMIT ' . $this->limit; } $sql = "SELECT * FROM " . $this->table . $indexList; $result = $sqlQuery->execute($sql); if ($result['status']) { foreach ($result['data'] as $item) { $this->processItem($item); } } }
/** * {@inheritdoc} */ public function handleBatch(array $records) { $level = $this->level; // filter records based on their level $records = array_filter($records, function ($record) use($level) { return $record['level'] >= $level; }); if (!$records) { return; } // the record with the highest severity is the "main" one $record = array_reduce($records, function ($highest, $record) { if ($record['level'] >= $highest['level']) { return $record; } return $highest; }); // the other ones are added as a context item $logs = array(); foreach ($records as $r) { $logs[] = $this->processRecord($r); } if ($logs) { $record['context']['logs'] = (string) $this->getBatchFormatter()->formatBatch($logs); } $this->handle($record); }
/** * @inheritdoc */ public function execute() { $pipes = array_reverse($this->pipes); /** @type \Closure $linked_closure */ $linked_closure = array_reduce($pipes, $this->getIterator(), $this->getInitial($this->thenClosure)); return $linked_closure(...$this->parameters); }
/** * Get loaded shipping method given its id * * @param CartInterface $cart Cart * @param string $shippingMethodId Shipping method id * * @return ShippingMethod|null Required shipping method */ public function getOneById(CartInterface $cart, $shippingMethodId) { $shippingMethods = $this->get($cart); return array_reduce($shippingMethods, function ($foundShippingMethod, ShippingMethod $shippingMethod) use($shippingMethodId) { return $shippingMethodId === $shippingMethod->getId() ? $shippingMethod : $foundShippingMethod; }, null); }
public function setUp() { $source1 = new Source(array('generate' => function ($size) { $r = ''; for ($i = 0; $i < $size; $i++) { $r .= chr($i); } return $r; })); $source2 = new Source(array('generate' => function ($size) { $r = ''; for ($i = $size - 1; $i >= 0; $i--) { $r .= chr($i); } return $r; })); $sources = array($source1, $source2); $mixer = new Mixer(array('mix' => function (array $sources) { if (empty($sources)) { return ''; } $start = array_pop($sources); return array_reduce($sources, function ($el1, $el2) { return $el1 ^ $el2; }, $start); })); $this->generator = new Generator($sources, $mixer); }
/** * @param object|null $relatedEntity * @param string|null $query * @param Organization|null $organization * @param int $limit * * @return array */ public function getEmailRecipients($relatedEntity = null, $query = null, Organization $organization = null, $limit = 100) { $emails = []; foreach ($this->providers as $provider) { if ($limit <= 0) { break; } $args = new EmailRecipientsProviderArgs($relatedEntity, $query, $limit, array_reduce($emails, 'array_merge', []), $organization); $recipients = $provider->getRecipients($args); if (!$recipients) { continue; } $limit = max([0, $limit - count($recipients)]); if (!array_key_exists($provider->getSection(), $emails)) { $emails[$provider->getSection()] = []; } $emails[$provider->getSection()] = array_merge($emails[$provider->getSection()], $recipients); } $result = []; foreach ($emails as $section => $sectionEmails) { $items = array_map(function (Recipient $recipient) { return $this->emailRecipientsHelper->createRecipientData($recipient); }, $sectionEmails); $result[] = ['text' => $this->translator->trans($section), 'children' => array_values($items)]; } return $result; }
/** * [Custom event handler which performs action] * * @param Doku_Event $event event object by reference * @param mixed $param [the parameters passed as fifth argument to register_hook() when this * handler was registered] * @return void */ public function handle_auth_user_change(Doku_Event &$event, $param) { if ($event->data['type'] !== 'create') { return; } $domains = array_map(function ($domain) { return trim($domain); }, explode(';', $this->getConf('_domainWhiteList'))); $email = $event->data['params'][3]; $checks = array(in_array(trim(substr(strrchr($email, "@"), 1)), $domains), (bool) preg_match($this->getConf('_emailRegex', '/@/'), $email)); if ($this->getConf('checksAnd', true)) { $status = array_reduce($checks, function ($a, $b) { return $a && $b; }, true); } else { $status = array_reduce($checks, function ($a, $b) { return $a || $b; }, false); } if (!$status) { $event->preventDefault(); $event->stopPropagation(); $event->result = false; msg($this->getConf('_domainlistErrorMEssage'), -1); } }
/** * @param string $classname * @return array */ public function getFieldsMetadata($classname) { foreach ($this->getReflectionClass($classname)->getProperties() as $property) { $properties = array_reduce($this->reader->getPropertyAnnotations($property), function ($reduced, $current) use($property, $classname) { if ($current instanceof AbstractField) { $current->name = $property->getName(); if (is_object($classname)) { $property->setAccessible(true); $current->value = $property->getValue($classname); } $key = get_class($current); if (isset($reduced[$key])) { if (!is_array($reduced[$key])) { $reduced[$key] = [$reduced[$key]]; } $reduced[$key][] = $current; } else { $reduced[$key] = $current; } return $reduced; } }); if (!is_null($properties)) { $fields[$property->getName()] = $properties; } } return $fields; }
/** * Remove orphans from disk * * @param array $filesToRemove * @param InputInterface $input * @param OutputInterface $output * @return int */ protected function _removeMediaFiles(&$filesToRemove, InputInterface $input, OutputInterface $output) { if (count($filesToRemove) < 1) { // Nothing to do return 0; } $quiet = $input->getOption('quiet'); $totalSteps = $this->_getTotalSteps(); $currentStep = $this->_getCurrentStep(); $this->_advanceNextStep(); !$quiet && $output->writeln("<comment>Remove files from filesystem</comment> ({$currentStep}/{$totalSteps})"); $progress = new ProgressBar($output, count($filesToRemove)); $unlinkedCount = array_reduce($filesToRemove, function ($unlinkedCount, $info) use($progress, $quiet) { $unlinked = unlink($info); !$quiet && $progress->advance(); return $unlinkedCount + $unlinked; }, 0); if (!$quiet) { $progress->finish(); if ($unlinkedCount < 1) { $output->writeln("\n <error>NO FILES DELETED! do you even have write permissions?</error>\n"); } else { $output->writeln("\n <info>...and it's gone... removed {$unlinkedCount} files</info>\n"); } } return $unlinkedCount; }
/** * Validate * * @param mixed $value * @return boolean */ public function validate($value) { $messenger = $this->messenger->clear(); return array_reduce($this->func, function (&$result, $func) use($value, $messenger) { return $result && $func($value, $messenger); }, true); }
private function formatColumns() { return array_reduce($this->columns, function ($c, Column $column) { $c[] = $column->toArray(); return $c; }, []); }
/** * Fetches the version of the latest stable release. * * By Default, this uses the GitHub API (v3) and only returns refs that begin with * 'tags/release-'. Because GitHub returns the refs in alphabetical order, * we need to reduce the array to a single value, comparing the version * numbers with version_compare(). * * If $service is set to VERSION_SERVICE_ZEND this will fall back to calling the * classic style of version retreival. * * * @see http://developer.github.com/v3/git/refs/#get-all-references * @link https://api.github.com/repos/zendframework/zf2/git/refs/tags/release- * @link http://framework.zend.com/api/zf-version?v=2 * @param string $service Version Service with which to retrieve the version * @return string */ public static function getLatest($service = self::VERSION_SERVICE_GITHUB) { if (null === static::$latestVersion) { static::$latestVersion = 'not available'; if ($service == self::VERSION_SERVICE_GITHUB) { $url = 'https://api.github.com/repos/zendframework/zf2/git/refs/tags/release-'; $apiResponse = Json::decode(file_get_contents($url), Json::TYPE_ARRAY); // Simplify the API response into a simple array of version numbers $tags = array_map(function ($tag) { return substr($tag['ref'], 18); // Reliable because we're filtering on 'refs/tags/release-' }, $apiResponse); // Fetch the latest version number from the array static::$latestVersion = array_reduce($tags, function ($a, $b) { return version_compare($a, $b, '>') ? $a : $b; }); } elseif ($service == self::VERSION_SERVICE_ZEND) { $handle = fopen('http://framework.zend.com/api/zf-version?v=2', 'r'); if (false !== $handle) { static::$latestVersion = stream_get_contents($handle); fclose($handle); } } } return static::$latestVersion; }
/** * Generate the columns configuration * * @param array $data Data array * @return array Columns configuration */ public static function getColumnsConfiguration(array $data) { $config = array(); $lastColumns = null; foreach (array('large', 'medium', 'small') as $media) { $columns = isset($data['rs_columns_' . $media]) ? $data['rs_columns_' . $media] : null; if (!$columns) { $columns = $lastColumns ?: '2'; } $lastColumns = $columns; $columns = array_map(function ($value) { return (int) $value ?: 1; }, explode('-', $columns)); if (count($columns) === 1 && $columns[0] > 1) { $columns = array_fill(0, (int) $columns[0], '1'); } $columnsTotal = array_reduce($columns, function ($a, $b) { return $a + $b; }); $classes = array(); foreach ($columns as $key => $column) { $classes[] = array('-' . $media . '-col-' . $columnsTotal . '-' . $column); } $classes[0][] = '-' . $media . '-first'; $classes[count($classes) - 1][] = '-' . $media . '-last'; $config[$media] = $classes; } return $config; }
public function setUp() { $source1 = $this->getMock('RandomLib\\Source'); $source1->expects($this->any())->method('generate')->will($this->returnCallback(function ($size) { $r = ''; for ($i = 0; $i < $size; $i++) { $r .= chr($i); } return $r; })); $source2 = $this->getMock('RandomLib\\Source'); $source2->expects($this->any())->method('generate')->will($this->returnCallback(function ($size) { $r = ''; for ($i = $size - 1; $i >= 0; $i--) { $r .= chr($i); } return $r; })); $this->mixer = $this->getMock('RandomLib\\Mixer'); $this->mixer->expects($this->any())->method('mix')->will($this->returnCallback(function (array $sources) { if (empty($sources)) { return ''; } $start = array_pop($sources); return array_reduce($sources, function ($el1, $el2) { return $el1 ^ $el2; }, $start); })); $this->sources = array($source1, $source2); $this->generator = new Generator($this->sources, $this->mixer); }
/** * Extract entity ids from rows by identifier. * @param array $rows * @param string $idField * * @return array */ protected function extractEntityIds(array $rows, $idField) { return array_reduce($rows, function ($entityIds, ResultRecord $item) use($idField) { $entityIds[] = $item->getValue($idField); return $entityIds; }, []); }
protected function _commands_for_files(&$commands) { extract($this->params); $dir = wp_upload_dir(); $dist_path = constant(WP_Deploy_Flow_Command::config_constant('path')) . '/'; $remote_path = $dist_path; $local_path = ABSPATH; $excludes = array_merge($excludes, array('.git', '.sass-cache', 'wp-content/cache', 'wp-content/_wpremote_backups', 'wp-config.php')); if (!$ssh_host) { // in case the source env is in a subfolder of the destination env, we exclude the relative path to the source to avoid infinite loop $remote_local_path = realpath($local_path); if ($remote_local_path) { $remote_path = realpath($remote_path); $remote_local_path = str_replace($remote_path . '/', '', $remote_local_path); $excludes[] = $remote_locale_path; } } $excludes = array_reduce($excludes, function ($acc, $value) { $acc .= "--exclude \"{$value}\" "; return $acc; }); if ($ssh_host) { $commands[] = array("rsync -avz -e 'ssh -p {$ssh_port}' {$ssh_user}@{$ssh_host}:{$remote_path} {$local_path} {$excludes}", true); } else { $commands[] = array("rsync -avz {$remote_path} {$local_path} {$excludes}", true); } }
private function CheckNoEmpty() { $line = array_reduce($this->grid, function ($carry, $item) { return array_merge($carry, $item); }, []); return !in_array(NON_PLAYER, $line); }
public function makeRequest(FormattedRequestInterface $request, \FS\Components\Shipping\RequestBuilder\Factory\RequestBuilderFactory $factory) { $request->setRequestPart('address', $this->makeRequestPart($factory->getBuilder('ShipperAddress', array('type' => 'order')), $this->payload)); $request->setRequestPart('courier', strtolower($this->payload['courier'])); $request->setRequestPart('boxes', array_reduce($this->payload['orders'], function ($carry, $order) { $shipment = $order->getFlagShipRaw(); if (!$shipment) { return $carry; } $carry += count($shipment['packages']); return $carry; }, 0)); $request->setRequestPart('weight', array_reduce($this->payload['orders'], function ($carry, $order) { $shipment = $order->getFlagShipRaw(); if (!$shipment) { return $carry; } $carry += array_reduce($shipment['packages'], function ($weight, $package) { $weight += $package['weight']; return $weight; }, 0); return $carry; }, 0)); $request->setRequestPart('date', $this->payload['date']); $request->setRequestPart('from', $this->payload['options']->get('default_pickup_time_from', '09:00')); $request->setRequestPart('until', $this->payload['options']->get('default_pickup_time_to', '17:00')); $request->setRequestPart('units', 'imperial'); $request->setRequestPart('location', 'Reception'); $request->setRequestPart('to_country', $this->payload['orders'][0]->getWcOrder()->shipping_country); $request->setRequestPart('is_ground', $this->payload['type'] == 'domestic_ground' || $this->payload['type'] == 'international_ground'); return $request; }
/** * {@inheritDoc} * * @param array $data * * @return $data */ public function process(array $data) { $process = function (array $data, callable $processor) { return $processor($data); }; return array_reduce($this->processors, $process, $data); }
public function traverse(callable $f, $monad) { // Initial value for the fold: an empty array wrapped in a default // context. $init = $monad->pure([]); // Define the folding function. $foldingFn = function ($acc, $curr) use($f, $monad) { // Call $f on the current value of the array, $curr. The return // value should be a monadic value. try { $returnedMonad = $f($curr); // If the result is null, we fail. if (is_null($returnedMonad)) { $returnedMonad = $monad->fail('A call the callable passed to `AssociativeArray::traverse` returned null.'); } } catch (\Exception $e) { $returnedMonad = $monad->fail('A call the callable passed to `AssociativeArray::traverse` threw an exception: ' . $e->getMessage()); } // Put the value wrapped by the above monadic value in the array // held by the accumulator, $acc, to get the new accumulator. $newAcc = $returnedMonad->flatMap(function ($newVal) use($acc) { return $acc->map(function ($arr) use($newVal) { $arr[] = $newVal; return $arr; }); }); return $newAcc; }; // Do the fold. $result = array_reduce($this->array, $foldingFn, $init); return $result; }
public function _openConnection($environment) { $config = new Garp_Deploy_Config(); $params = $config->getParams($environment); if (!$params) { Garp_Cli::errorOut('No settings found for environment ' . $environment); } if (empty($params['server'])) { Garp_Cli::errorOut("'server' is a required setting."); return false; } // To provide a bit of backward-compatibility, convert to array if (!is_array($params['server'])) { $params['server'] = array(array('server' => $params['server'], 'user' => $params['user'])); } if (count($params['server']) === 1) { $this->_executeSshCommand($params['server'][0]['server'], $params['server'][0]['user']); return true; } $choice = Garp_Cli::prompt("Choose a server to use: \n" . array_reduce($params['server'], function ($output, $server) { $number = count(explode("\n", $output)); $output .= "{$number}) {$server['server']}\n"; return $output; }, '')); if (!array_key_exists($choice - 1, $params['server'])) { Garp_Cli::errorOut('Invalid choice: ' . $choice); return false; } $this->_executeSshCommand($params['server'][$choice - 1]['server'], $params['server'][$choice - 1]['user']); }
public function assertRoute($spec, array $routes) { $this->assertTrue(array_reduce($routes, function ($found, $route) use($spec) { if ($found) { return $found; } if ($route->getPath() !== $spec['path']) { return false; } if ($route->getMiddleware() !== $spec['middleware']) { return false; } if (isset($spec['allowed_methods'])) { if ($route->getAllowedMethods() !== $spec['allowed_methods']) { return false; } } if (!isset($spec['allowed_methods'])) { if ($route->getAllowedMethods() !== Route::HTTP_METHOD_ANY) { return false; } } return true; }, false)); }
/** * {@inheritdoc} */ public function summary() { $language_list = language_list(LanguageInterface::STATE_ALL); $selected = $this->configuration['langcodes']; // Reduce the language list to an array of language names. $language_names = array_reduce($language_list, function (&$result, $item) use($selected) { // If the current item of the $language_list array is one of the selected // languages, add it to the $results array. if (!empty($selected[$item->getId()])) { $result[$item->getId()] = $item->name; } return $result; }, array()); // If we have more than one language selected, separate them by commas. if (count($this->configuration['langcodes']) > 1) { $languages = implode(', ', $language_names); } else { // If we have just one language just grab the only present value. $languages = array_pop($language_names); } if (!empty($this->configuration['negate'])) { return t('The language is not @languages.', array('@languages' => $languages)); } return t('The language is @languages.', array('@languages' => $languages)); }
public function up(EventEmitterInterface $globalEmitter) { $eq = $this->eq; $collectionService = $this->collectionService; $themeService = $this->themeService; $themeService->getEventEmitter()->on(ThemeService::EVENT_DELETE, function (Theme $theme) use($eq, $collectionService) { array_reduce($eq->getCollectionsByThemeId($theme->getId()), function (CollectionThemeEQEntity $eq) use($collectionService) { $collection = $collectionService->getCollectionById($eq->getCollectionId()); $collection->setThemeIds(array_filter($collection->getThemeIds(), function ($input) use($eq) { return (int) $input !== (int) $eq->getThemeId(); })); if (!count($collection->getThemeIds())) { $collection->setPublicOptions(['is_private' => $collection->isPrivate(), 'public_enabled' => false, 'moderation_contract' => false]); } // TODO:: Notification about turning off public $this->collectionRepository->saveCollection($collection); }); }); $collectionService->getEventEmitter()->on(CollectionService::EVENT_COLLECTION_CREATED, function (Collection $collection) use($eq) { $eq->sync($collection->getId(), $collection->getThemeIds()); }); $collectionService->getEventEmitter()->on(CollectionService::EVENT_COLLECTION_EDITED, function (Collection $collection) use($eq) { $eq->sync($collection->getId(), $collection->getThemeIds()); }); $collectionService->getEventEmitter()->on(CollectionService::EVENT_COLLECTION_DELETE, function (Collection $collection) use($eq) { $eq->deleteEQOfCollection($collection->getId()); }); }
/** * @Route("/{id}/marketorders", name="api.corporation.marketorders", options={"expose"=true}) * @ParamConverter(name="corp", class="AppBundle:Corporation") * @Method("GET") * @Secure(roles="ROLE_DIRECTOR") */ public function indexAction(Corporation $corp) { $this->denyAccessUnlessGranted(AccessTypes::VIEW, $corp, 'Unauthorized access!'); $repo = $this->getDoctrine()->getRepository('AppBundle:MarketOrder'); $newestGroup = $this->getDoctrine()->getRepository('AppBundle:MarketOrderGroup')->getLatestMarketOrderGroup($corp); if (!$newestGroup instanceof MarketOrderGroup) { return $this->jsonResponse(json_encode(['error' => 'not found']), 400); } $orders = $repo->getBuyOrders($newestGroup); $sellorders = $repo->getSellOrders($newestGroup); $total_onMarket = array_reduce($sellorders, function ($carry, $data) { if ($carry === null) { return $data->getVolumeRemaining() * $data->getPrice(); } return $carry + $data->getVolumeRemaining() * $data->getPrice(); }); $total_escrow = array_reduce($orders, function ($carry, $data) { if ($carry === null) { return $data->getEscrow(); } return $carry + $data->getEscrow(); }); $merged_orders = array_values(array_merge($orders, $sellorders)); $updated_orders = $this->get('app.itemdetail.manager')->updateDetails($merged_orders); $merged_orders = $updated_orders; $items = ['items' => $merged_orders, 'total_escrow' => $total_escrow, 'total_on_market' => $total_onMarket]; $json = $this->get('jms_serializer')->serialize($items, 'json'); return $this->jsonResponse($json); }
private function consecutiveChars($password, &$strength) { // Number of consecutive characters of each class preg_match_all('/[a-z]{2,}/', $password, $matches); $strength->nConsecAlphaLowerCase = array_reduce($matches[0], function ($result, $item) { if (count($item) !== 0) { $result = $result + UTF8Utils::utf8Strlen($item) - 1; } return $result; }); preg_match_all('/[A-Z]{2,}/', $password, $matches); $strength->nConsecAlphaUpperCase = array_reduce($matches[0], function ($result, $item) { if (count($item) !== 0) { $result = $result + UTF8Utils::utf8Strlen($item) - 1; } return $result; }); preg_match_all('/[0-9]{2,}/', $password, $matches); $strength->nConsecNumber = array_reduce($matches[0], function ($result, $item) { if (count($item) !== 0) { $result = $result + UTF8Utils::utf8Strlen($item) - 1; } return $result; }); }
function simplemap_inclusions_form($form, &$form_state) { $cthelper = new ContentTypesLoader(); $smhelper = new SitemapDefinitionsLoader(); // Loads the available Content-Types (those who don't have a sitemap defined). $load_available_cts = function () use($cthelper) { $ct_without_sitemap = $cthelper->loadNotInSitemap(); return array_reduce($ct_without_sitemap, function ($result, $ctype) { $result[$ctype->type] = $ctype->name; return $result; }, []); }; // Creates a row for the Content-Types list. $create_rows = function () use($cthelper, $smhelper) { $sitemap_defs = $smhelper->loadDefinitions(); return array_reduce($sitemap_defs, function ($res, $sitemap_def) use($smhelper) { // Load the names of all the content types in this sitemap. $content_types = $smhelper->loadCTsInSitemap($sitemap_def->sitemap_name); $ct_names = array_map(function ($ct) { return $ct->name; }, $content_types); $internationalize = $sitemap_def->internationalize ? t('Yes') : t('No'); $delete_link = l(t('Delete Sitemap'), "admin/settings/simplemap/inclusions/{$sitemap_def->sitemap_name}/delete"); $row = [implode(', ', $ct_names), $sitemap_def->sitemap_name, $internationalize, $delete_link]; array_push($res, $row); return $res; }, []); }; $form = ['new_inclusion' => ['#type' => 'fieldset', '#title' => t('Add a New Content Type to the Sitemap'), 'content_type' => ['#type' => 'select', '#title' => t('Content Type'), '#options' => $load_available_cts(), '#multiple' => true, '#required' => true], 'sitemap_name' => ['#type' => 'textfield', '#title' => t('Name of the Sitemap File'), '#required' => true], 'internationalize' => ['#type' => 'checkbox', '#title' => t('Internationalize')], 'submit' => ['#type' => 'submit', '#value' => t('Add to the Sitemap')]], 'existing_sitemaps' => ['#type' => 'fieldset', '#title' => t('Already Defined Sitemaps'), 'list' => ['#theme' => 'table', '#header' => [t('Content Types'), t('Sitemap'), t('Internationalize'), ''], '#rows' => $create_rows()]]]; return $form; }