/** * Parse a query string into a Query object * * @param string $query Query string to parse * * @return self */ public static function fromString($query) { $q = new static(); if ($query === '') { return $q; } $foundDuplicates = $foundPhpStyle = false; foreach (explode('&', $query) as $kvp) { $parts = explode('=', $kvp, 2); $key = rawurldecode($parts[0]); if ($paramIsPhpStyleArray = substr($key, -2) == '[]') { $foundPhpStyle = true; $key = substr($key, 0, -2); } if (isset($parts[1])) { $value = rawurldecode(str_replace('+', '%20', $parts[1])); if (isset($q[$key])) { $q->add($key, $value); $foundDuplicates = true; } elseif ($paramIsPhpStyleArray) { $q[$key] = array($value); } else { $q[$key] = $value; } } else { $q->add($key, null); } } // Use the duplicate aggregator if duplicates were found and not using // PHP style arrays. if ($foundDuplicates && !$foundPhpStyle) { $q->setAggregator(self::duplicateAggregator()); } return $q; }
/** * Parse a query string into a QueryString object * * @param string $query Query string to parse * * @return self */ public static function fromString($query) { $q = new static(); if (0 !== strlen($query)) { if ($query[0] == '?') { $query = substr($query, 1); } foreach (explode('&', $query) as $kvp) { $parts = explode('=', $kvp, 2); $key = rawurldecode($parts[0]); $paramIsPhpStyleArray = substr($key, -2) == '[]'; if ($paramIsPhpStyleArray) { $key = substr($key, 0, -2); } if (array_key_exists(1, $parts)) { $value = rawurldecode(str_replace('+', '%20', $parts[1])); if ($paramIsPhpStyleArray && !$q->hasKey($key)) { $value = array($value); } $q->add($key, $value); } else { $q->add($key, ''); } } } return $q; }
public static function request() { $class = new static(); !Input::has('deleteShippingMethod') ?: $class->delete(Input::get('deleteShippingMethod')); !Input::has('updateShippingMethod') ?: $class->update(Input::get('updateShippingMethod'))->with(Input::get('shipping.fill')); !Input::has('addShippingMethod') ?: $class->add()->with(Input::get('shipping.fill')); }
private function nextWorkingDay($current) { if ($current->format('H') < 19 && !$this->isSunday($current) && !$this->isWeekend($current) && !$this->isHoliday($current)) { $next = new static($current->format('Y-m-d ' . static::DEFAULT_OFFICE_CLOSE_TIME), $this->timezone); } else { $next = new static($current->format('Y-m-d ' . static::DEFAULT_OFFICE_CALL_TIME), $this->timezone); $i = 0; // We have 0 future dates to start with while ($i < 1) { $next->add(new DateInterval('P1D')); // Add 1 day if ($this->isHoliday($next)) { continue; } // Don't include year to ensure the check is year independent // Note that you may need to do more complicated things for special holidays that don't use specific dates like "the last Friday of this month" if ($this->isWeekend($next)) { continue; } // These next lines will only execute if continue isn't called for this iteration $i++; } } return $next; }
public static function request() { $class = new static(); $class->acton = Input::get('action'); !Input::has('deleteSearch') ?: $class->delete(Input::get('deleteSearch')); $class->action != 'addSearch' ?: $class->add(Input::get('search'), Input::get('users')); }
public static function request() { $class = new static(); !Input::has('deletePaymentMethod') ?: $class->delete(Input::get('deletePaymentMethod')); !Input::has('updatePaymentMethod') ?: $class->update(Input::get('updatePaymentMethod'))->with(Input::get('payment.fill')); !Input::has('addPaymentMethod') ?: $class->add()->with(Input::get('payment.fill')); }
/** * @ignore */ public static function fromFileScan($uPattern) { $tSep = quotemeta(DIRECTORY_SEPARATOR); $tPos = strrpos($uPattern, $tSep); if ($tSep !== '/' && $tPos === false) { $tSep = '/'; $tPos = strrpos($uPattern, $tSep); } if ($tPos !== false) { $tPattern = substr($uPattern, $tPos + strlen($tSep)); $tPath = substr($uPattern, 0, $tPos + strlen($tSep)); } else { $tPath = $uPattern; $tPattern = ""; } $tTemp = new static(); $tHandle = new \DirectoryIterator($tPath); $tPatExists = strlen($uPattern) > 0; for (; $tHandle->valid(); $tHandle->next()) { if (!$tHandle->isFile()) { continue; } $tFile = $tHandle->current(); if ($tPatExists && !fnmatch($tPattern, $tFile)) { continue; } $tTemp->add($tPath . $tFile); } return $tTemp; }
public static function request() { $class = new static(); Input::get('action') != 'addComment' ?: $class->add(Input::all()); !Input::has('hideComment') ?: $class->hide(head(Input::get('hideComment', []))); !Input::has('unhideComment') ?: $class->unhide(head(Input::get('unhideComment', []))); !Input::has('deleteComment') ?: $class->delete(head(Input::get('deleteComment', []))); }
/** * @param string $type_ * * @return \Components\Object_Properties */ public static function forType($type_) { $instance = new static($type_); foreach (self::arrayForType($type_) as $property) { $instance->add($property['name'], $property['type'], $property['nameMapped'], $property['typeMapped']); } return $instance; }
/** * @param array $strings * * @return static */ public static function fromArray(array $strings) { $list = new static(); foreach ($strings as $oneString) { $list->add($oneString); } return $list; }
/** * convenience method to create a simple failure report * * @param string $message * @param mixed $errors * @return common_report_Report */ public static function createFailure($message, $errors = array()) { $report = new static(self::TYPE_ERROR, $message); foreach ($errors as $error) { $report->add($error); } return $report; }
public static function fromConfig($config) { $collection = new static(); foreach ($config as $key => $config) { $collection->add($key, $config); } return $collection; }
/** * A handy starter for creating a button group with buttons. * @param array $buttons * @return ButtonGroup */ public static function build(array $buttons = []) { $group = new static(); foreach ($buttons as $button) { $group->add($button); } return $group; }
/** * @param CommandInterface $cmd * @return ResponseCollection */ public function getCommandResult(CommandInterface $cmd) { $collection = new static(); foreach (new ResponseFilterIterator($this, $cmd) as $response) { $collection->add($response); } return $collection; }
/** * Construct the result based on the given xml. * @param SimpleXMLElement $xmlElement * @return \CultuurNet\Search\SuggestionsResult */ public static function fromXml(SimpleXMLElement $xmlElement) { $result = new static(); foreach ($xmlElement->xpath('//suggestion') as $xmlSuggestion) { $result->add(SuggestionsItem::fromXml($xmlSuggestion)); } return $result; }
public static function createRandomProducts($numberOfProducts = 1) { $collection = new static(); for ($i = $numberOfProducts; $i > 0; $i--) { $collection->add(new Product()); } return $collection; }
public static function request() { $class = new static(); Input::get('action') != 'addMessage' ?: $class->add(Input::get('communication')); !Input::has('hideMessage') ?: $class->hide(head(Input::get('hideMessage', []))); !Input::has('unhideMessage') ?: $class->unhide(head(Input::get('unhideMessage', []))); !Input::has('deleteMessage') ?: $class->delete(head(Input::get('deleteMessage', []))); }
/** * Loads a configuration file * * @param string|array $uPath path of configuration file to be loaded * * @return mixed */ public static function load($uPath) { $tInstance = new static(); foreach ((array) $uPath as $tPath) { $tInstance->add($tPath); } return $tInstance; }
/** * Create From a Directory * * @param string $namespace The namespace attach to the directory * @param string $directory The directory path * * @return static */ public static function createFromFileSystem($namespace, $directory) { $collection = new static(); foreach (new FilesystemIterator($directory) as $fileInfo) { $className = $namespace . '\\' . $fileInfo->getBasename('.php'); $collection->add(new $className()); } return $collection; }
public static function createForManifest(Manifest $manifest, string $pathToZip) : Zip { $zip = new static($pathToZip); $zip->open(); foreach ($manifest->files() as $file) { $zip->add($file, self::determineNameOfFileInZip($file, $pathToZip)); } $zip->close(); return $zip; }
/** * Merge couple of bags into one. * * Type of return object depends on invocation context. Return object is as same * type as class used in invocation (late state binding). * * @param array $bags Array of Bag objects * @return Bag Single Bag object contains merged data */ public static function merge(array $bags) { $mergedBag = new static(); foreach ($bags as $bag) { foreach ($bag->getAll() as $name => $value) { $mergedBag->add($name, $value); } } return $mergedBag; }
/** * Return errors for a specific property. * Use null to return errors without a property reference. * Returns ErrorCollection * * @param null|string $property_name The property name or null to get errors without a property name * * @return static A collection of zero or more Error objects */ public function byProperty($property_name = null) { $result = new static(); foreach ($this as $error) { if ($property_name === $error->getProperty()) { $result->add($error); } } return $result; }
/** * Actions for attributes based on Request. * @return void */ public static function request() { $class = new static(); $class->action = Input::get('action'); $newValue = Input::get('newValue'); $newName = Input::get('newName'); $renameAttrName = Input::get('renameAttrName'); !starts_with($class->action, "deleteAttrValue") ?: $class->delete(substr($class->action, 16)); $class->action != 'newAttribute' ?: $class->add($newName, $newValue); $class->rename($renameAttrName)->update(Input::all()); event('veer.message.center', trans('veeradmin.attribute.update')); }
public static function request() { $class = new static(); !Input::has('updateBillStatus') ?: $class->setId(Input::get('updateBillStatus'))->status(Input::get('billUpdate.' . Input::get('updateBillStatus') . '.status_id'))->comment(Input::get('billUpdate.' . Input::get('updateBillStatus'))); !Input::has('updateBillSend') ?: $class->setId(head(Input::get('updateBillSend', [])))->markAsSent(); !Input::has('updateBillPaid') ?: $class->setId(head(Input::get('updateBillPaid', [])))->markAsPaid(key(Input::get('updateBillPaid', []))); !Input::has('updateBillCancel') ?: $class->setId(head(Input::get('updateBillCancel', [])))->markAsCancel(key(Input::get('updateBillCancel', []))); !Input::has('deleteBill') ?: $class->setId(Input::get('deleteBill'))->delete(); if (Input::has('addNewBill') && Input::has('billCreate.fill.orders_id')) { $class->add(Input::get('billCreate.fill'), Input::get('billCreate.template')); } }
/** * Parse a query string into a QueryString object * * @param string $query Query string to parse * * @return QueryString */ public static function fromString($query) { $q = new static(); if (!empty($query)) { if ($query[0] == '?') { $query = substr($query, 1); } foreach (explode('&', $query) as $kvp) { $parts = explode('=', $kvp); $key = rawurldecode($parts[0]); if (substr($key, -2) == '[]') { $key = substr($key, 0, -2); } if (array_key_exists(1, $parts)) { $q->add($key, rawurldecode(str_replace('+', '%20', $parts[1]))); } else { $q->add($key, ''); } } } return $q; }
/** * * @return void */ public static function request() { //\Event::fire('router.filter: csrf'); $class = new static(); $class->action = Input::get('action'); if (Input::has('id')) { return $class->one(); } $class->updateRestrictions(Input::get('changeRestrictUser')); $class->updateBan(Input::get('changeStatusUser')); $class->delete(Input::get('deleteUser')); $class->add($class->action == 'Add' ? Input::all() : null); }
/** * Parse a query string into a QueryString object * * @param string $query Query string to parse * * @return QueryString */ public static function fromString($query) { $q = new static(); foreach (explode('&', $query) as $kvp) { $parts = explode('=', $kvp); $key = rawurldecode($parts[0]); if (substr($key, -2) == '[]') { $key = substr($key, 0, -2); } $value = array_key_exists(1, $parts) ? rawurldecode($parts[1]) : null; $q->add($key, $value); } return $q; }
/** * @deprecated * @param int $pkgIsInstalled * @return static */ public static function get($pkgIsInstalled = 1) { $pkgList = CacheLocal::getEntry('pkgList', $pkgIsInstalled); if ($pkgList != false) { return $pkgList; } $em = \Database::connection()->getEntityManager(); $r = $em->getRepository('\\Concrete\\Core\\Entity\\Package'); $packages = $r->findBy(array('pkgIsInstalled' => true), array('pkgID' => 'asc')); $list = new static(); foreach ($packages as $pkg) { $list->add($pkg); } CacheLocal::set('pkgList', $pkgIsInstalled, $list); return $list; }
/** * @param array $routes * @param int $index * @param ViewController $content * @param bool $keepActiveLink * * @return $this|TabContainer */ public static function fromRoute(array $routes, int $index, ViewController $content, bool $keepActiveLink = false) : self { $container = new static(); foreach ($routes as $currentIndex => $route) { $container->add($tab = new Tab($route['name'])); if ($index == $currentIndex) { $tab->add($content)->setActive(); } if (isset($route['routeName']) && (!isset($route['disabled']) || $route['disabled'] == false) && ($keepActiveLink || $index != $currentIndex)) { $tab->setHref((string) self::uri($route['routeName'], $route['routeArgs'] ?? [])); } if (isset($route['disabled']) && $route['disabled']) { $tab->setDisabled(true); } } return $container; }
public static function get($pkgIsInstalled = 1) { $pkgList = CacheLocal::getEntry('pkgList', $pkgIsInstalled); if ($pkgList != false) { return $pkgList; } $db = Loader::db(); $r = $db->query("select pkgID, pkgName, pkgIsInstalled, pkgDescription, pkgVersion, pkgHandle, pkgDateInstalled from Packages where pkgIsInstalled = ? order by pkgID asc", array($pkgIsInstalled)); $list = new static(); while ($row = $r->fetchRow()) { $pkg = new Package(); $pkg->setPropertiesFromArray($row); $list->add($pkg); } CacheLocal::set('pkgList', $pkgIsInstalled, $list); return $list; }