sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
public function selectMultipleOptionsInChosen($label, $options)
{
$select = $this->findField($label);
$selectID = $select->getAttribute('id');
$chosenSelectID = $selectID . '_chzn';
foreach ($options as $option)
{
$this->debug("I open the $label chosen selector");
$this->click(array('xpath' => "//div[... | Selects one or more options in a Chosen Multiple Select based on its label
@param string $label Label of the select field
@param array $options Array of options to be selected
@return void
@since 3.0.0 | entailment |
public function doAdministratorLogout()
{
$this->click(array('xpath' => "//ul[@class='nav nav-user pull-right']//li//a[@class='dropdown-toggle']"));
$this->debug("I click on Top Right corner toggle to Logout from Admin");
$this->waitForElement(array('xpath' => "//li[@class='dropdown open']/ul[@class='dropdown-me... | Function to Logout from Administrator Panel in Joomla!
@return void
@since 3.0.0
@throws \Exception | entailment |
public function enablePlugin($pluginName)
{
$this->amOnPage('/administrator/index.php?option=com_plugins');
$this->debug('I check for Notices and Warnings');
$this->checkForPhpNoticesOrWarnings();
$this->searchForItem($pluginName);
$this->waitForElement($this->searchResultPluginName($pluginName), 30);
$thi... | Function to Enable a Plugin
@param String $pluginName Name of the Plugin
@return void
@since 3.0.0
@throws \Exception | entailment |
public function uninstallExtension($extensionName)
{
$this->amOnPage('/administrator/index.php?option=com_installer&view=manage');
$this->waitForText('Extensions: Manage', '30', array('css' => 'H1'));
$this->searchForItem($extensionName);
$this->waitForElement(array('id' => 'manageList'), '30');
$this->click... | Uninstall Extension based on a name
@param string $extensionName Is important to use a specific
@return void
@since 3.0.0
@throws \Exception | entailment |
public function searchForItem($name = null)
{
if ($name)
{
$this->debug("Searching for $name");
$this->fillField(array('id' => "filter_search"), $name);
$this->click(array('xpath' => "//button[@type='submit' and @data-original-title='Search']"));
return;
}
$this->debug('clearing search filter');
... | Function to Search For an Item in Joomla! Administrator Lists views
@param String $name Name of the Item which we need to Search
@return void
@since 3.0.0 | entailment |
public function installLanguage($languageName)
{
$this->amOnPage('administrator/index.php?option=com_installer&view=languages');
$this->debug('I check for Notices and Warnings');
$this->checkForPhpNoticesOrWarnings();
$this->debug('Refreshing languages');
$this->click(array('xpath' => "//div[@id='toolbar-ref... | Function to install a language through the interface
@param string $languageName Name of the language you want to install
@return void
@throws \Exception | entailment |
public function setModulePosition($module, $position = 'position-7')
{
$this->amOnPage('administrator/index.php?option=com_modules');
$this->searchForItem($module);
$this->click(array('link' => $module));
$this->waitForText("Modules: $module", 30, array('css' => 'h1.page-title'));
$this->click(array('link' =... | Publishes a module on frontend in given position
@param string $module The full name of the module
@param string $position The template position of a module. Right position by default
@return void
@throws \Exception | entailment |
public function publishModule($module)
{
$this->amOnPage('administrator/index.php?option=com_modules');
$this->searchForItem($module);
$this->checkAllResults();
$this->click(array('xpath' => "//div[@id='toolbar-publish']/button"));
$this->waitForText(' published.', 30, array('id' => 'system-message-container... | Publishes a module on all frontend pages
@param string $module The full name of the module
@return void
@since 3.0.0
@throws \Exception | entailment |
public function displayModuleOnAllPages($module)
{
$this->amOnPage('administrator/index.php?option=com_modules');
$this->searchForItem($module);
$this->click(array('link' => $module));
$this->waitForElement(array('link' => 'Menu Assignment'), 30);
$this->click(array('link' => 'Menu Assignment'));
$this->wa... | Changes the module Menu assignment to be shown on all the pages of the website
@param string $module The full name of the module
@return void
@since 3.0.0
@throws \Exception | entailment |
public function clickToolbarButton($button)
{
$input = strtolower($button);
$screenSize = explode("x", $this->config['window_size']);
if ($screenSize[0] <= 480)
{
$this->click('Toolbar');
}
switch ($input)
{
case "new":
$this->click(array('xpath' => "//div[@id='toolbar-new']//button"));
... | Function to select Toolbar buttons in Joomla! Admin Toolbar Panel
@param string $button The full name of the button
@return void
@since 3.0.0 | entailment |
public function createMenuItem($menuTitle, $menuCategory, $menuItem, $menu = 'Main Menu', $language = 'All')
{
$this->debug("I open the menus page");
$this->amOnPage('administrator/index.php?option=com_menus&view=menus');
$this->waitForText('Menus', TIMEOUT, array('css' => 'H1'));
$this->checkForPhpNoticesOrWa... | Creates a menu item with the Joomla menu manager, only working for menu items without additional required fields
@param string $menuTitle The menu item title
@param string $menuCategory The category of the menu type (for example Weblinks)
@param string $menuItem The menu item type / link text (for e... | entailment |
public function setFilter($label, $value)
{
$label = strtolower($label);
$filters = array(
"select status" => "filter_published",
"select access" => "filter_access",
"select language" => "filter_language",
"select tag" => "filter_tag",
"select max levels" => "filter_level"
);
$this->click(... | Function to filter results in Joomla! Administrator.
@param string $label Label of the Filter you want to use.
@param string $value Value you want to set in the filters.
@return void
@since 3.0.0 | entailment |
public function verifyAvailableTabs($expectedTabs, $tabsLocator = array('xpath' => "//ul[@id='myTabTabs']/li/a"))
{
$actualArrayOfTabs = $this->grabMultiple($tabsLocator);
$this->debug("Fetch the current list of Tabs in the edit view which is: " . implode(", ", $actualArrayOfTabs));
$url = $this->grabFromCurren... | Function to Verify the Tabs on a Joomla! screen
@param array $expectedTabs Expected Tabs on the Page
@param Mixed $tabsLocator Locator for the Tabs in Edit View
@return void
@since 3.0.0 | entailment |
public function disableStatistics()
{
$this->debug('I click on never');
$this->wait(1);
$this->waitForElement(array('link' => 'Never'), TIMEOUT);
$this->click(array('link' => 'Never'));
} | Hide the statistics info message
{@internal doAdminLogin() before}
@return void
@since 3.5.0
@throws \Exception | entailment |
public function createCategory($title, $extension = '')
{
$this->debug('Category creation in /administrator/');
$this->doAdministratorLogin();
if (!empty($extension))
{
$extension = '&extension=' . $extension;
}
$this->amOnPage('administrator/index.php?option=com_categories' . $extension);
$this->w... | Create a new category
@param string $title Title of the new category
@param string $extension Optional extension to use
@return void
@since 3.7.5
@throws \Exception | entailment |
public function createUser($name, $username, $password, $email, $userGroup = 'Super Users')
{
$this->debug('User creation');
$this->doAdministratorLogin();
$this->amOnPage('administrator/index.php?option=com_users');
$this->waitForElement(array('class' => 'page-title'));
$this->checkForPhpNoticesOrWarnings... | Create a user in the administrator site
@param string $name Name
@param string $username User name (login)
@param string $password Password
@param string $email Email
@param string $userGroup Group id to attach to the user
@return void
@since 3.8.11
@throws \Exception | entailment |
public function leaves(\WP_Query $query)
{
/** @var \stdClass $term */
$term = $query->get_queried_object();
if (!isset($term->slug) || !isset($term->term_id)) {
return ['category'];
}
return [
"category-{$term->slug}",
"category-{$term->t... | {@inheritdoc} | entailment |
public function dispatch(\Parable\Routing\Route $route)
{
$this->dispatchedRoute = $route;
$this->hook->trigger(self::HOOK_DISPATCH_BEFORE, $route);
$controller = null;
// Start output buffering and set $returnContent to null
$returnContent = null;
$this->response->... | Dispatch the provided route.
@param \Parable\Routing\Route $route
@return $this | entailment |
public function image($path, array $options = array())
{
if ('text' == $this->getType()) {
return null;
}
return parent::image($path, $this->_mergeAttributes($options, $this->config('attributes.image')));
} | {@inheritdoc} | entailment |
public function link($title, $url = null, array $options = array())
{
$url = Router::url($url, ['full' => true]);
if ('html' == $this->getType()) {
return parent::link($title, $url, $this->_mergeAttributes($options, $this->config('attributes.link')));
}
if (empty($url))... | {@inheritdoc} | entailment |
public function media($path, array $options = array())
{
if ('text' == $this->getType()) {
return;
}
return parent::media($path, $this->_mergeAttributes($options, $this->config('attributes.media')));
} | {@inheritdoc} | entailment |
public function para($class, $text, array $options = array())
{
if ('text' == $this->getType()) {
return $this->_eol() . $this->_eol() . $text . $this->_eol() . $this->_eol();
}
return parent::para($class, $text, $this->_mergeAttributes($options, $this->config('attributes.para')... | {@inheritdoc} | entailment |
public function table($content, $options = array())
{
if ('text' == $this->getType()) {
return $content;
}
if (false === $options) {
return $this->config('templates.tableend');
}
$tag = 'table';
if (is_null($content)) {
$tag = 'ta... | Creates table.
@param string $content
@param array $options
@return string | entailment |
public function viewport($content = null)
{
if (empty($content)) {
$content = 'width=device-width, initial-scale=1.0';
}
if (is_array($content)) {
$content = implode(', ', $content);
}
return $this->meta(array('name' => 'viewport', 'content' => $conten... | Viewport meta.
@param mixed $content
@return string | entailment |
protected function _mergeAttributes($attrs, $merge)
{
$appendable = array(
'class' => array('separator' => ' ', 'match' => 'full'),
'style' => array('separator' => ';', 'match' => 'part'),
);
foreach ((array)$merge as $attr => $values) {
if (
!array_k... | Merge attributes.
@param array $attrs Passed attributes.
@param array $merge Default attributes.
@return array | entailment |
public function setCode4User(UserInterface $userEntity, $type, $expire = null)
{
$entityManager = $this->entityManager;
$this->getRepositoryManager()->deleteCodes4User($userEntity->getId(), $type);
do {
$found = false;
$code = $this->formatService->getCode();
... | @param UserInterface $userEntity
@param string $type
@param int|null $expire
@return string | entailment |
public function deleteCode(Entity $userCode)
{
$entityManager = $this->entityManager;
$entityManager->remove($userCode);
$entityManager->flush();
} | delete a userCode from database
@param Entity $userCode | entailment |
public function cleanExpireCodes($limit = 100)
{
$codeList = $this->getRepositoryManager()->getExpiredCodes($limit);
$result = 0;
if ($codeList) {
$result = $this->cleanExpireCodes4List($codeList);
}
return $result;
} | @param int $limit
@return int | entailment |
protected function cleanExpireCodes4List(array $codeList)
{
$i = 0;
$entityManager = $this->entityManager;
foreach ($codeList as $code) {
try {
$entityManager->remove($code);
// if we have a register-code, so we have to remove the user too
... | @param Entity[] $codeList
@return int | entailment |
protected function entityToString($entity)
{
return method_exists($entity, '__toString') ? (string) $entity : get_class($entity) . '@' . spl_object_hash($entity);
} | @param object $entity
@return string | entailment |
private function parse(\WP_Query $query = null)
{
(is_null($query) && isset($GLOBALS['wp_query'])) and $query = $GLOBALS['wp_query'];
$data = (object)['hierarchy' => [], 'templates' => [], 'query' => $query];
$branches = self::$branches;
// make the branches filterable, but assuri... | Parse all branches.
@param \WP_Query $query
@return \stdClass | entailment |
private function parseBranch(\stdClass $data, $branchClass)
{
/** @var \Brain\Hierarchy\Branch\BranchInterface $branch */
$branch = new $branchClass();
$name = $branch->name();
$isFilterable = ($this->flags & self::FILTERABLE) > 0;
// When branches are filterable, we need thi... | @param string $branchClass
@param \stdClass $data
@return \stdClass | entailment |
public function setCurrentPlayer($extraPlayer = 0)
{
try {
$player = $this->gameBackendService->getCurrentPlayerNumber();
} catch (\Exception $e) {
$player = 0;
}
if ($player > 0) {
$player += $extraPlayer;
}
$class = $this->colle... | read from GameBackend the current player [or] as param and save them in database
@param int $extraPlayer | entailment |
public function outputCurrentPlayerImage()
{
$playerNumber = $this->getCurrentPlayer();
$image = imagecreate(250, 50);
//set the background color of the image
$color = $this->collectionOptions->getGeneralOptions()->getImagePlayer()['background_color'];
imagecolorallocate($i... | output the player online image | entailment |
public function pageAction()
{
$type = $this->params()->fromRoute('type');
$pageInfo = $this->pageInfoService->getPage4Type($type);
if (!$pageInfo) {
return $this->redirect()->toRoute('PServerCore');
}
return [
'pageInfo' => $pageInfo
];
} | DynamicPages | entailment |
public function getStatisticData($lastDays = 10)
{
$timestamp = DateTimer::getZeroTimeStamp(strtotime('-' . $lastDays - 1 . ' days'));
$dateTime = DateTimer::getDateTime4TimeStamp($timestamp);
$donateEntity = $this->getDonateLogEntity();
$typList = $donateEntity->getDonateTypes();
... | @param int $lastDays
@return array | entailment |
public function createQuery()
{
$query = \Parable\ORM\Query::createInstance();
$query->setTableName($this->getTableName());
return $query;
} | Generate a query set to use the current Model's table name & key.
@return \Parable\ORM\Query | entailment |
public function save()
{
$array = $this->toArrayWithoutEmptyValues();
$query = $this->createQuery();
$now = (new \DateTime())->format('Y-m-d H:i:s');
if ($this->{$this->getTableKey()}) {
$query->setAction('update');
$query->where($query->buildAndSet([
... | Saves the model, either inserting (no id) or updating (id).
@return bool | entailment |
public function delete()
{
$query = $this->createQuery();
$query->setAction('delete');
$query->where($query->buildAndSet([$this->getTableKey(), '=', $this->id]));
$result = $this->database->query($query);
return $result ? true : false;
} | Deletes the current model from the database.
@return bool | entailment |
public function populate(array $data)
{
foreach ($data as $property => $value) {
if (property_exists($this, $property)) {
$this->{$property} = $value;
}
}
return $this;
} | Populates the current model with the data provided.
@param array $data
@return $this; | entailment |
public function toArray($keepNullValue = false)
{
$reflection = new \ReflectionClass(static::class);
$arrayData = [];
foreach ($reflection->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) {
$value = $property->getValue($this);
// We don't want to add eit... | Generates an array of the current model, without the protected values.
@param bool $keepNullValue
@return array
@throws \ReflectionException | entailment |
public function toArrayWithoutEmptyValues()
{
$array = $this->removeEmptyValues($this->toArray(true));
foreach ($array as $key => $value) {
if ($value === \Parable\ORM\Database::NULL_VALUE) {
$array[$key] = null;
}
}
return $array;
} | Generates an array of the current model, but removes empty values.
@return array | entailment |
public function toMappedArray(array $array)
{
$mappedArray = [];
foreach ($this->getMapper() as $from => $to) {
$mappedArray[$to] = $array[$from];
}
return $mappedArray;
} | Attempts to use stored mapper array to map fields from the current model's properties to what is set in the
array.
@param array $array
@return array | entailment |
public function exportToArray()
{
$data = $this->toArray();
if (count($this->exportable) === 0) {
return $data;
}
$exportData = [];
foreach ($data as $key => $value) {
if (in_array($key, $this->exportable)) {
$exportData[$key] = $data... | Export to array, which will exclude unexportable keys
@return array | entailment |
public function reset()
{
$reflection = new \ReflectionClass(static::class);
foreach ($reflection->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) {
if (!$property->isStatic()) {
$this->{$property->getName()} = null;
}
}
return $thi... | Reset all public properties to null.
@return $this
@throws \ReflectionException | entailment |
public function isCountryAllowedForUser($userId, $country)
{
$query = $this->createQueryBuilder('p')
->select('p')
->where('p.user = :userId')
->setParameter('userId', $userId)
->getQuery();
$data = $query->getResult();
$return = false;
... | @param $userId
@param $country
@return bool | entailment |
public function setRequired($required)
{
if (!in_array(
$required,
[
\Parable\Console\Parameter::PARAMETER_REQUIRED,
\Parable\Console\Parameter::PARAMETER_OPTIONAL,
]
)) {
throw new \Parable\Console\Exception('Required m... | Set whether this argument is required.
@param int $required
@return $this
@throws \Parable\Console\Exception | entailment |
public function init()
{
parent::init();
self::$plugin = $this;
Craft::$app->getView()->registerTwigExtension(new EnvironmentLabelTwigExtension());
Event::on(
View::class,
View::EVENT_BEFORE_RENDER_PAGE_TEMPLATE,
function (Event $event) {
EnvironmentLabel::$plugin->label->doItBaby();
}
... | Initializes the plugin, sets its static self-reference, registers the Twig extension,
and adds the environment label as appropriate. | entailment |
public function send($to, $subject, $body, $headers)
{
return mail(
$to,
$subject,
$body,
$headers
);
} | Send using PHPs built-in Mail interface
@inheritdoc
@codeCoverageIgnore | entailment |
protected function loadCommands(PackageInterface $package)
{
if (!$package->getCommands() || APP_CONTEXT !== 'console') {
return $this;
}
$commandLoader = \Parable\DI\Container::create(\Parable\Framework\Loader\CommandLoader::class);
$commandLoader->load($package->getCom... | Load all Commands from package.
@param PackageInterface $package
@return $this
@throws \Parable\DI\Exception | entailment |
public function registerPackages()
{
foreach ($this->packages as $packageName) {
$package = \Parable\DI\Container::create($packageName);
$this->loadCommands($package);
$this->loadInits($package);
}
return $this;
} | Register all packages with Parable.
@return $this
@throws \Parable\DI\Exception | entailment |
protected function loadInits(PackageInterface $package)
{
if (!$package->getInits()) {
return $this;
}
$initLoader = \Parable\DI\Container::create(\Parable\Framework\Loader\InitLoader::class);
$initLoader->load($package->getInits());
return $this;
} | Load all Inits from package.
@param PackageInterface $package
@return $this
@throws \Parable\DI\Exception | entailment |
public function load(array $commandClasses)
{
foreach ($commandClasses as $commandClass) {
$command = \Parable\DI\Container::create($commandClass);
$this->consoleApp->addCommand($command);
}
return $this;
} | Add all commands passed to the console app.
@param string[] $commandClasses
@return $this
@throws \Parable\DI\Exception | entailment |
public function up()
{
Schema::create('ipn_orders', function (Blueprint $table) {
$table->increments('id');
$table->string('notify_version', 64)->nullable();
$table->string('verify_sign', 127)->nullable();
$table->integer('test_ipn')->nullable();
$... | Run the migrations.
@return void | entailment |
public function addCommand(\Parable\Console\Command $command)
{
$command->prepare($this, $this->output, $this->input, $this->parameter);
$this->commands[$command->getName()] = $command;
return $this;
} | Add a command to the application.
@param \Parable\Console\Command $command
@return $this | entailment |
public function setDefaultCommand(\Parable\Console\Command $command)
{
$this->addCommand($command);
$this->setDefaultCommandByName($command->getName());
return $this;
} | Set the default command to use if no command is given. Also
adds the command.
@param \Parable\Console\Command $command
@return $this | entailment |
public function run()
{
$defaultCommand = null;
$command = null;
if ($this->defaultCommand) {
$defaultCommand = $this->getCommand($this->defaultCommand);
}
if (!$this->shouldOnlyUseDefaultCommand()) {
$commandName = $this->parameter->getCommand... | Run the application.
@return mixed
@throws \Parable\Console\Exception | entailment |
public function getOrder()
{
$request = $this->getRequestHandler();
$listener = new PayPalListener($request);
$listener->setMode($this->getEnvironment());
if ($listener->verifyIpn()) {
return $this->store($request->getData());
} else {
throw new Inva... | Listens for and stores PayPal IPN requests.
@return IpnOrder
@throws InvalidIpnException
@throws UnexpectedResponseBodyException
@throws UnexpectedResponseStatusException | entailment |
public function getRequestHandler()
{
$config = Config::get('paypal-ipn-laravel::request_handler', 'auto');
if ($config == 'curl' || ($config == 'auto' && is_callable('curl_init'))) {
return new CurlRequest(Input::all());
} else {
return new SocketRequest(Input::all()... | Get the request handler.
@return Request | entailment |
private function store($data)
{
if (array_key_exists('txn_id', $data)) {
$order = IpnOrder::firstOrNew(array('txn_id' => $data['txn_id']));
$order->fill($data);
} else {
$order = new IpnOrder($data);
}
$order->full_ipn = json_encode(Input::all());
... | Stores the IPN contents and returns the IpnOrder object.
@param array $data
@return IpnOrder | entailment |
private function storeOrderItems($order, $data)
{
$cart = isset($data['num_cart_items']);
$numItems = (isset($data['num_cart_items'])) ? $data['num_cart_items'] : 1;
for ($i = 0; $i < $numItems; $i++) {
$suffix = ($numItems > 1 || $cart) ? ($i + 1) : '';
$suffixUnde... | Stores the order items from the IPN contents.
@param IpnOrder $order
@param array $data | entailment |
private function postType(\WP_Query $query)
{
$type = $query->get('post_type');
is_array($type) and $type = reset($type);
$object = get_post_type_object($type);
(is_object($object) && $object->has_archive) or $type = '';
return $type;
} | @param \WP_Query $query
@return mixed|string | entailment |
public function trigger($event = null, &$payload = null)
{
// Disallow calling a trigger on global docks
if ($event === '*') {
return $this;
}
// Get all global docks
$globalDocks = [];
if (isset($this->docks['*']) && count($this->docks['*']) > 0) {
... | Trigger $event and run through all docks referenced, passing along $payload to all $callables.
@param null|string $event
@param null|mixed $payload
@return $this|bool | entailment |
public function isValid($value)
{
$result = true;
$this->setValue($value);
$type = $this->getOption('type');
$blackList = $this->config['blacklisted'][$type];
if (!$blackList) {
return $result;
}
foreach ($blackList as $entry) {
if (... | Returns true if and only if $value meets the validation requirements
If $value fails validation, then this method returns false, and
getMessages() will return an array of messages that explain why the
validation failed.
@param mixed $value
@return bool
@throws Exception\RuntimeException If validation of $value is i... | entailment |
protected function editBlackListedData(string $data, string $type): string
{
if ($type == self::TYPE_EMAIL) {
$data = sprintf('@%s', $data);
}
return $data;
} | @param string $data
@return string | entailment |
public function add($cacheKey, $content, $status = 200, $headers = [], $expires = Cache::HOUR)
{
$file = File::create();
$file->setStatus($status);
$file->setContent($content);
$file->setRoute($cacheKey);
$file->setHeaders($headers);
if ($expires > 0) {
$f... | Adds a cache entry with a given key, content and for a set amount of time
The time by default for the cache is an hour
@param $cacheKey
@param $content
@param int $status
@param array $headers
@param int $expires
@throws CacheFileSystemException | entailment |
public function setQuery(\Parable\ORM\Query $query)
{
$this->query = $query;
$this->setTableName($query->getTableName());
return $this;
} | Set the query.
@param \Parable\ORM\Query $query
@return $this | entailment |
public function setShouldCompareFields($shouldCompareFields)
{
// We need to set shouldQuoteValues to the opposite of shouldCompareFields
$this->shouldQuoteValues = !$shouldCompareFields;
$this->shouldCompareFields = (bool)$shouldCompareFields;
return $this;
} | Set whether the fields should be compared rather than values. If so, quoteValues is set to inverted value.
@param bool $shouldCompareFields
@return $this | entailment |
public function build()
{
$value = $this->getValue();
$this->uppercaseComparator();
// Check for IS/IS NOT and set the value to NULL if it is.
if ($this->isComparatorIsNotNullIsNull()) {
$value = null;
}
// Check for IN/NOT IN and build a nice comma-sep... | Build the condition to a string.
@return string | entailment |
public function get($configString, $default = false)
{
// Check if we have a cache
if (isset($this->cache[$configString])) {
return $this->cache[$configString];
}
$valueList = explode('.', $configString);
$config = $this->config;
foreach ($valueList as $v... | @param $configString
@param bool $default
@return mixed | entailment |
public function load(array $initClasses)
{
foreach ($initClasses as $initClass) {
\Parable\DI\Container::create($initClass);
}
return $this;
} | Load array of init classes.
@param string[] $initClasses
@return $this
@throws \Parable\DI\Exception | entailment |
public function getCountryCode4Ip(int $decimalIp): string
{
$query = $this->createQueryBuilder('p')
->select('p')
->where('p.ipMin <= :ip')
->andWhere('p.ipMax >= :ip')
->setParameter('ip', $decimalIp)
->getQuery();
/** @var \PServerCore\E... | @param int $decimalIp
@return string | entailment |
public function getDescription4CountryCode(string $cntry): string
{
$query = $this->createQueryBuilder('p')
->select('p')
->where('p.cntry = :sCntry')
->setParameter('sCntry', $cntry)
->setMaxResults(1)
->getQuery();
/** @var \PServerCore\... | @param string $cntry
@return string | entailment |
public function getNews4Id($newsId)
{
$query = $this->createQueryBuilder('p')
->select('p')
->where('p.id = :newsId')
->setParameter('newsId', $newsId)
->getQuery();
return $query->getOneOrNullResult();
} | @param $newsId
@return null|\PServerCore\Entity\News | entailment |
private function enableCompilation(ContainerBuilder $builder): bool
{
$path = $this->definitions[$this::CONFIG][$this::DI_CACHE_PATH] ?? null;
if ($path) {
$builder->enableCompilation($path);
return is_file(rtrim($path, '/') . '/CompiledContainer.php');
}
re... | @param ContainerBuilder $builder
@return bool true if compilation is enabled and CompiledContainer exists. | entailment |
private function parseArgs(array $args)
{
if (! count($args)) {
return $this->createHelpArgument();
}
$arg1 = array_shift($args);
if (in_array($arg1, ['-h', '--help', 'help'], true)) {
return $this->createHelpArgument();
}
if (! count($args)... | @param array $args
@return \stdClass | entailment |
private function help($resource = STDOUT)
{
$this->helper->writeLine(sprintf(
self::HELP_TEMPLATE,
$this->scriptName
), true, $resource);
} | @param resource $resource Defaults to STDOUT
@return void | entailment |
public function findFirst(array $templates, $type)
{
$found = '';
while (!empty($templates) && $found === '') {
$found = $this->find(array_shift($templates), $type) ?: '';
}
return $found;
} | @param array $templates
@param string $type
@return string
@see \Brain\Hierarchy\Finder\TemplateFinderInterface::findFirst() | entailment |
public function doAuthentication(UserInterface $user)
{
/** @var \PServerCore\Entity\Repository\User $repository */
$repository = $this->entityManager->getRepository($this->getUserEntityClassName());
// fix if we have a proxy we don´t have a valid entity, so we have to clear before we can c... | Login with a User
@param UserInterface $user | entailment |
protected function bCrypt($password)
{
if ($this->isSamePasswordOption()) {
$result = $this->gameDataService->hashPassword($password);
} else {
$bCrypt = new Bcrypt();
$result = $bCrypt->create($password);
}
return $result;
} | We want to crypt a password =)
@param $password
@return string | entailment |
public function leaves(\WP_Query $query)
{
/** @var \WP_Post $post */
$post = $query->get_queried_object();
if (!$post instanceof \WP_Post || ! $post->ID) {
return ['single'];
}
$leaves = [
"single-{$post->post_type}-{$post->post_name}",
"... | {@inheritdoc} | entailment |
protected function fetchControllerSuffix()
{
// Validate that we have a map to handle the given HTTP method.
if (!isset($this->suffixMap[$this->input->getMethod()]))
{
throw new \RuntimeException(sprintf('Unable to support the HTTP method `%s`.', $this->input->getMethod()), 404);
}
// Check if request me... | Get the controller class suffix string.
@return string
@since 1.0
@throws \RuntimeException
@deprecated 2.0 Use the base Router class instead | entailment |
protected function parseRoute($route)
{
$name = parent::parseRoute($route);
// Append the HTTP method based suffix.
$name .= $this->fetchControllerSuffix();
return $name;
} | Parse the given route and return the name of a controller mapped to the given route.
@param string $route The route string for which to find and execute a controller.
@return string The controller name for the given route excluding prefix.
@since 1.0
@throws \InvalidArgumentException
@deprecated 2.0 Use t... | entailment |
public static function get($className, $parentClassName = '')
{
$className = self::cleanName($className);
// We store the relationship between class & parent to prevent cyclical references
if ($parentClassName) {
self::$relations[$className][$parentClassName] = true;
}
... | Return an already instantiated instance or create a new one.
@param string $className
@param string $parentClassName
@return mixed
@throws \Parable\DI\Exception | entailment |
protected static function createInstance($className, $parentClassName = '', $createAll = false)
{
$className = self::cleanName($className);
try {
$dependencies = self::getDependenciesFor($className, $createAll);
} catch (\Parable\DI\Exception $e) {
$message = $e->get... | Instantiate a class and fulfill its dependency requirements.
@param string $className
@param string $parentClassName
@param bool $createAll
@return mixed
@throws \Parable\DI\Exception | entailment |
public static function getDependenciesFor($className, $createAll = false)
{
try {
$reflection = new \ReflectionClass($className);
} catch (\Exception $e) {
$message = "Could not create instance of '{$className}'";
throw new \Parable\DI\Exception($message);
... | Retrieve and instantiate all dependencies for the provided $className
@param string $className
@param bool $createAll
@return array
@throws \Parable\DI\Exception | entailment |
public static function store($instance, $name = null)
{
if (!$name) {
$name = get_class($instance);
}
$name = self::cleanName($name);
self::$instances[$name] = $instance;
} | Store an instance under either the provided $name or its class name.
@param object $instance
@param string|null $name | entailment |
public static function clearExcept(array $keepInstanceNames)
{
foreach (self::$instances as $name => $instance) {
if (!in_array($name, $keepInstanceNames)) {
self::clear($name);
}
}
} | Remove all stored instances but KEEP the passed instance names.
@param string[] $keepInstanceNames | entailment |
public function discardUpperMigrations(Bundle $bundle)
{
$drivers = array_keys($this->getAvailablePlatforms());
$currentVersion = $this->migrator->getCurrentVersion($bundle);
$this->log("Deleting migration classes above version {$currentVersion} for '{$bundle->getName()}'...");
$hasD... | Deletes migration classes which are above the current version of a bundle.
@param \Symfony\Component\HttpKernel\Bundle\Bundle $bundle | entailment |
public function getAvailablePlatforms()
{
$platforms = array();
foreach ($this->getSupportedDrivers() as $driverName => $driverClass) {
$driver = new $driverClass;
$platforms[$driverName] = $driver->getDatabasePlatform();
}
return $platforms;
} | Returns the list of available driver platforms.
Note: this method is public for testing purposes only
@return array[AbstractPlatform] | entailment |
public static function getDateRange4Period(DateTime $beginDate, DateTime $endDate)
{
$result = [];
if ($beginDate < $endDate) {
do {
$result[] = clone $beginDate;
$beginDate->modify('+1 day');
} while ($beginDate <= $endDate);
}
... | @param DateTime $beginDate
@param DateTime $endDate
@return DateTime[] | entailment |
public function load($templatePath)
{
$production = !defined('WP_DEBUG') || !WP_DEBUG;
ob_start();
if (!$production) {
/** @noinspection PhpIncludeInspection */
require $templatePath;
} elseif (file_exists($templatePath)) {
/** @noinspection PhpIn... | {@inheritdoc} | entailment |
public function leaves(\WP_Query $query)
{
/** @var \WP_Post $post */
$post = $query->get_queried_object();
$post instanceof \WP_Post or $post = new \WP_Post((object) ['ID' => 0]);
$template = $this->postTemplates->findFor($post);
$pagename = $query->get('pagename');
... | {@inheritdoc} | entailment |
public static function parseExtensions($extensions, $trimPattern = ". \t\n\r\0\x0B")
{
$parsed = [];
$extensions = is_string($extensions) ? explode('|', $extensions) : (array) $extensions;
foreach ($extensions as $extension) {
if (is_string($extension)) {
$extensi... | @param string|string[] $extensions
@param string $trimPattern
@return \string[] | entailment |
public function getHeader($key)
{
foreach ($this->headers as $header => $content) {
if (strtolower($key) === strtolower($header)) {
return $content;
}
}
return null;
} | Return header by key if it exists.
@param string $key
@return null|string | entailment |
public function getScheme()
{
if (isset($_SERVER['REQUEST_SCHEME'])) {
// Apache 2.4+
return $_SERVER['REQUEST_SCHEME'];
}
if (isset($_SERVER['REDIRECT_REQUEST_SCHEME'])) {
return $_SERVER['REDIRECT_REQUEST_SCHEME'];
}
if (isset($_SERVER['H... | Return the current scheme.
This is surprisingly annoying due to unreliable availability of $_SERVER values.
@return string | entailment |
public function getHttpHost()
{
if (isset($_SERVER['HTTP_HOST'])
&& isset($_SERVER['SERVER_NAME'])
&& $_SERVER['HTTP_HOST'] === $_SERVER['SERVER_NAME']
) {
return $_SERVER['HTTP_HOST'];
}
if (isset($_SERVER['HTTP_HOST'])) {
return $_SE... | Return the http host, if possible.
@return null|string | entailment |
public function getAll()
{
if (!$this->getResource()) {
return [];
}
if ($this->useLocalResource) {
return $this->localResource;
}
// If we're attempting to use a global resource but it doesn't exist, we've got a problem.
if (!isset($GLOBALS[$... | Return all from resource if resource is set.
@return array
@throws \Parable\GetSet\Exception | entailment |
public function get($key, $default = null)
{
$resource = $this->getAll();
$keys = explode('.', $key);
foreach ($keys as $key) {
if (!isset($resource[$key])) {
$resource = $default;
break;
}
$resource = &$resource[$key];
... | Return specific value by key if resource set. If not found, return default.
$getSet->get("one.two.three", "value") would return $resource["one"]["two"]["three"] or "value";
@param string $key
@param mixed|null $default
@return mixed|null | entailment |
public function getAndRemove($key)
{
$data = $this->get($key);
if ($data) {
$this->remove($key);
}
return $data;
} | Return specific value by key and then clear it.
@param string $key
@return mixed|null | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.