sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
protected function hasOneThrough( $referenceModel, $intermediaryModel, $intermediaryCurrentForeignKey = null, $intermediaryReferenceForeignKey = null ) { return (new Relations\HasOneThrough( new Relations\Maps\Intermediary($this, $referenceModel, $intermediaryMode...
RelationTrait::hasOneThrough @param string|Model $referenceModel @param string|Model $intermediaryModel @param string|null $intermediaryCurrentForeignKey @param string|null $intermediaryReferenceForeignKey @param string|null $primaryKey @return bool|\O2System\Framework\Models\Sql\DataObjects\Result
entailment
protected function hasMany($referenceModel, $foreignKey = null) { return (new Relations\HasMany( new Relations\Maps\Reference($this, $referenceModel, $foreignKey) ))->getResult(); }
RelationTrait::hasMany Has Many is a one to many relationship, is used to define relationships where a single reference model owns any amount of others relation model. @param string|Model $referenceModel String of table name or AbstractModel @param string|null $foreignKey @return Result|bool
entailment
protected function hasManyThrough( $referenceModel, $intermediaryModel, $intermediaryCurrentForeignKey = null, $intermediaryReferenceForeignKey = null ) { return (new Relations\HasManyThrough( new Relations\Maps\Intermediary($this, $referenceModel, $intermediaryMo...
RelationTrait::hasManyThrough @param string|Model $referenceModel @param string|Model $intermediaryModel @param string|null $intermediaryCurrentForeignKey @param string|null $intermediaryReferenceForeignKey @param string|null $primaryKey @return bool|\O2System\Framework\Models\Sql\DataObjects\Result
entailment
public function setText($text) { $this->entity->setEntityName($text); $this->textContent->push($text); return $this; }
Alert::setText @param string $text @return static
entailment
public function render() { if ($this->dismissible) { $this->attributes->addAttributeClass('alert-dismissible'); $button = new Element('button'); $button->entity->setEntityName('button-dismiss'); $button->attributes->addAttribute('type', 'button'); ...
Alert::render @return string
entailment
public function style($style) { if (in_array($style, ['arrow', 'dot', 'bar'])) { $this->attributes->removeAttributeClass('breadcrumb-*'); $this->attributes->addAttributeClass('breadcrumb-' . $style); } return $this; }
Breadcrumb::style @param string $style @return static
entailment
protected function insertRecordSets(array &$sets) { $timestamp = $this->unixTimestamp === true ? strtotime(date('Y-m-d H:i:s')) : date('Y-m-d H:i:s'); if(is_null($this->recordUser)) { if(globals()->offsetExists('account')) { $this->setRecordUser(globals()->account->id); ...
RecordTrait::insertRecordSets @param array $sets
entailment
protected function updateRecordSets(array &$sets) { if(is_null($this->recordUser)) { if(globals()->offsetExists('account')) { $this->setRecordUser(globals()->account->id); } } if ( ! isset($sets[ 'record_status' ])) { $sets[ 'record_status...
RecordTrait::updateRecordSets @param array $sets
entailment
protected function mappingIntermediaryModel($intermediaryModel) { if ($intermediaryModel instanceof Model) { $this->intermediaryModel = $intermediaryModel; $this->intermediaryTable = $intermediaryModel->table; $this->intermediaryPrimaryKey = $this->intermediaryModel->prim...
Intermediary::mappingIntermediaryModel @param string|\O2System\Framework\Models\Sql\Model $intermediaryModel
entailment
public function getParent($id) { if ($parent = $this->qb ->from($this->table) ->where($this->parentKey, $id) ->get(1)) { if ($parent->count() == 1) { return $parent; } } return false; }
AdjacencyTrait::getParent @param int $id @return bool|\O2System\Framework\Models\Sql\DataObjects\Result\Row
entailment
public function getChilds($idParent) { if ($childs = $this->qb ->from($this->table) ->where($this->parentKey, $idParent) ->get()) { if ($childs->count() > 0) { return $childs; } } return false; }
AdjacencyTrait::getChilds @param int $idParent @return bool|\O2System\Framework\Models\Sql\DataObjects\Result
entailment
public function get(string $key, $default = null) { //get value from memcached $value = $this->memcached->get($key); //check if value was retrived if ($value === false) { return $default; } return $value; }
Fetches a value from the cache. @param string $key The unique key of this item in the cache. @param mixed $default Default value to return if the key does not exist. @return mixed The value of the item from the cache, or $default in case of cache miss.
entailment
public function has(string $key): bool { return ($this->memcached->get($key) !== false) ? true : false; }
Determines whether an item is present in the cache. NOTE: It is recommended that has() is only to be used for cache warming type purposes and not to be used within your live applications operations for get/set, as this method is subject to a race condition where your has() will return true and immediately after, anoth...
entailment
public function execute() { $options = input()->get(); if (empty($options)) { $_GET[ 'switch' ] = 'ON'; $_GET[ 'mode' ] = 'default'; $_GET[ 'lifetime' ] = 300; $_GET[ 'title' ] = language()->getLine(strtoupper('CLI_MAINTENANCE_TITLE')); $_...
Maintenance::execute @throws \Exception
entailment
protected static function discover_channel($channel_name) { $cfg = PEAR2\Pyrus\Config::current(); $registry = $cfg->channelregistry; if (isset($registry[$channel_name])) return; // already registered $channel_file = new PEAR2\Pyrus\ChannelFile('http://'.$channel_name.'/...
helpers
entailment
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { $this->config = $this->sessionManager->getConfig(); $this->sessionHandled = true; $isSessionAvailable = $request instanceof Request && $this->sessionConfigured(); // If a...
Process an incoming server request and return a response, optionally delegating response creation to a handler. @param \Psr\Http\Message\ServerRequestInterface $request @param \Psr\Http\Server\RequestHandlerInterface $handler @return \Psr\Http\Message\ResponseInterface @throws \RuntimeException @throws \InvalidArgumen...
entailment
protected function storeCurrentUrl(Request $request, SessionInterface $session) { if ($request->getMethod() === 'GET') { $session->setPreviousUrl($request->fullUrl()); } }
Store the current URL for the request if necessary. @param Request $request @param SessionInterface $session
entailment
private function addCookieToResponse(Request $request, Response $response, SessionInterface $session): Response { $uri = $request->getUri(); $path = '/'; $domain = $uri->getHost(); $secure = strtolower($uri->getScheme()) === 'https'; $httpOnly = true; return $response...
Add the session cookie to the response· @param Request $request @param Response $response @param SessionInterface $session @return Response @throws \InvalidArgumentException
entailment
protected function getCookieExpirationDate() { if (!empty($this->config['expire_on_close'])) { $expirationDate = 0; } else { $expirationDate = Carbon::now()->addMinutes(5 * 60); } return $expirationDate; }
Get the session lifetime in seconds. @return \DateTimeInterface|int
entailment
private function replaceExtractedValuesByLoadedValues(SearchResult $searchResult) { $valueObjectMapById = $this->loadValueObjectMapById($searchResult); foreach ($searchResult->searchHits as $index => $searchHit) { $id = $this->getValueObjectId($searchHit->valueObject); if (...
@param \eZ\Publish\API\Repository\Values\Content\Search\SearchResult $searchResult @return \eZ\Publish\API\Repository\Values\Content\Search\SearchResult
entailment
private function loadValueObjectMapById(SearchResult $searchResult) { if (!isset($searchResult->searchHits[0])) { return []; } $idList = $this->extractIdList($searchResult); if ($searchResult->searchHits[0]->valueObject instanceof ContentInfo) { return $this...
@param \eZ\Publish\API\Repository\Values\Content\Search\SearchResult $searchResult @return array|\eZ\Publish\SPI\Persistence\Content\ContentInfo[]
entailment
private function loadLocationMapByIdList(array $locationIdList) { if (method_exists($this->locationHandler, 'loadList')) { return $this->locationHandler->loadList($locationIdList); } $locationList = []; foreach ($locationIdList as $locationId) { try { ...
@param array $locationIdList @return array|\eZ\Publish\SPI\Persistence\Content\ContentInfo[]
entailment
public function extractHit($hit) { if ($hit->document_type_id === 'content') { return $this->contentHandler->loadContentInfo($hit->content_id_id); } if ($hit->document_type_id === 'location') { return $this->locationHandler->load($hit->location_id_id); } ...
{@inheritdoc} @throws \RuntimeException If search $hit could not be handled @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException
entailment
public function load(array $configs, ContainerBuilder $container) { $activatedBundlesMap = $container->getParameter('kernel.bundles'); $loader = new Loader\YamlFileLoader( $container, new FileLocator(__DIR__ . '/../../lib/Resources/config/') ); if (array_key...
@param array $configs @param \Symfony\Component\DependencyInjection\ContainerBuilder $container @throws \Exception
entailment
public function updateAverageNote() { $commentTableName = $this->em->getClassMetadata($this->commentManager->getClass())->table['name']; $threadTableName = $this->em->getClassMetadata($this->getClass())->table['name']; $this->em->getConnection()->beginTransaction(); $this->em->getCo...
Updates the threads average note from comments notes.
entailment
private function format_trace_flags() { $flags = array(); if (!$this->already_invoked) { $flags[] = 'first_time'; } if (!$this->is_needed()) { $flags[] = 'not_needed'; } return (count($flags)) ? '('.join(', ', $flags).')' : ''; }
Format the trace flags for display.
entailment
public static function get_mini_task_name($task_name) { $is_method_task = strpos($task_name, '::'); return ((false !== $is_method_task) ? substr($task_name, $is_method_task + 2) : $task_name); }
removes classname and colons, if those are present abc => abc abc::def => def @param string $task_name @return string
entailment
public static function abbrev(array $options) { $abbrevs = array(); $table = array(); foreach ($options as $option) { $short_option = pakeTask::get_mini_task_name($option); for ($len = (strlen($short_option)); $len > 0; --$len) { $abbrev = substr($short_option, 0,...
gets array of words as input and returns array, where shortened words are keys and arrays of corresponding full-words are values. For example: input: array('abc', 'abd') output: array('a' => array('abc', 'abd'), 'ab' => array('abc', 'abd'), 'abc' => array('abc'), 'abd' => array('abd')) @param array $options @return ar...
entailment
public function run(OutputInterface $output) { $this->output = $output; if (get_class($this) === ParallelTask::class) { $this->output->writeln( ['', sprintf(' <info>[%s]</info> - <comment>Starting</comment>', $this->getName()), ''] ); } $o...
{@inheritDoc}
entailment
private function runCommand(Process $process) { $output = $this->output; /** @type DebugFormatterHelper $debugFormatter */ $debugFormatter = $this->getHelperSet()->get('debug_formatter'); if (null !== $dispatcher = $this->getEventDispatcher()) { $event = new PreExecuteEv...
@param Process $process @return bool @throws TaskRuntimeException @throws \Bldr\Exception\BldrException @throws \Bldr\Exception\ParameterNotFoundException @throws \Bldr\Exception\RequiredParameterException
entailment
private function resolveCommands() { $commands = []; foreach ($this->getParameter('commands') as $cmd) { $commands[] = is_array($cmd) ? (new ProcessBuilder($cmd))->getProcess() : new Process($cmd); } return $commands; }
@return array|Process[] @throws \Bldr\Exception\ParameterNotFoundException @throws \Bldr\Exception\RequiredParameterException
entailment
private function read_php_argv() { global $argv; if (!is_array($argv)) { if (!@is_array($_SERVER['argv'])) { if (!@is_array($GLOBALS['HTTP_SERVER_VARS']['argv'])) { throw new pakeException("pakeGetopt: Could not read cmd args (register_argc_argv=Off?)."); } ...
Function from PEAR::Console_Getopt. Safely read the $argv PHP array across different PHP configurations. Will take care on register_globals and register_argc_argv ini directives @access public @return mixed the $argv PHP array
entailment
protected function doRequest($method, $apiMethod, array $data = []) { $url = $this->config['endpoint'] . $apiMethod; $data = $this->mergeData($this->createAuthData(), $data); $response = $this->getGuzzleClient()->request($method, $url, ['json' => $data]); $responseContent = \GuzzleH...
Send request to SalesManago API. @param string $method HTTP Method @param string $apiMethod API Method @param array $data Request data @return array
entailment
protected function createAuthData() { return [ 'clientId' => $this->config['client_id'], 'apiKey' => $this->config['api_key'], 'requestTime' => time(), 'sha' => sha1($this->config['api_key'] . $this->config['client_id'] . $this->config['api_secret']) ]...
Returns an array of authentication data. @return array
entailment
private function mergeData(array $base, array $replacements) { return array_filter(array_merge($base, $replacements), function($value) { return $value !== null; }); }
Merge data and removing null values. @param array $base The array in which elements are replaced @param array $replacements The array from which elements will be extracted @return array
entailment
public function set($domain, $key, $value = null) { $this->validateDomain($domain); if (null !== $value) { $this->profile[$domain][$key] = $value; } else { $this->profile[$domain] = $key; } }
Set a domain configuration. @param string $domain @param $key @param array|null $value
entailment
public function get($domain, $key = null) { $this->validateDomain($domain); if (null === $key) { return new Config($this->profile[$domain]); } if (!isset($this->profile[$domain][$key])) { throw new \InvalidArgumentException(sprintf( 'Unknown ...
Get a domain configuration. @param string $domain @param string $key @throws \InvalidArgumentException @return array
entailment
public function getBySku(SKU $sku) : Product { if (!array_key_exists((string) $sku, $this->products)) { throw ProductNotFoundException::bySku($sku); } return $this->products[(string) $sku]; }
@param SKU $sku @return Product @throws ProductNotFoundException
entailment
public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) { $fieldNames = $this->getFieldNames($criterion); if (empty($fieldNames)) { throw new InvalidArgumentException( '$criterion->target', "No searchable fields found for the give...
{@inheritdoc} @throws \eZ\Publish\Core\Base\Exceptions\InvalidArgumentException
entailment
protected function getFieldNames(Criterion $criterion) { $fieldDefinitionIdentifier = $criterion->target; $fieldMap = $this->contentTypeHandler->getSearchableFieldMap(); $fieldNames = []; foreach ($fieldMap as $contentTypeIdentifier => $fieldIdentifierMap) { if (!isset($...
Return all field names for the given criterion. @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion @return string[]
entailment
public function serialize($value) : string { if (!is_numeric($value)) { throw InvalidValueException::valueDoesNotMatchType($this, $value); } return (string) (float) $value; }
@param $value @return string @throws InvalidValueException
entailment
public static function coming_events($from = false) { $time = ($from ? strtotime($from) : mktime(0, 0, 0, date('m'), date('d'), date('Y'))); $sql = "(StartDateTime >= '".date('Y-m-d', $time)." 00:00:00')"; $events = PublicEvent::get()->where($sql); return $events; }
Get all coming public events
entailment
public static function coming_events_limited($from=false, $limit=30) { $events = self::coming_events($from)->limit($limit); return $events; }
Get all coming public events - with optional limit
entailment
public static function events_for_month($month) { $nextMonth = strtotime('last day of this month', strtotime($month)); $currMonthStr = date('Y-m-d', strtotime($month)); $nextMonthStr = date('Y-m-d', $nextMonth); $sql = "(StartDateTime BETWEEN '$currMonthStr' AND '$nextMonthStr')...
Get events for a specific month Format: 2013-07 @param type $month
entailment
public static function add_preview_params($link,$object) { // Pass through if not logged in if(!Member::currentUserID()) { return $link; } $modifiedLink = ''; $request = Controller::curr()->getRequest(); if ($request && $request->getVar('CMSPreview')) { ...
If applicable, adds preview parameters. ie. CMSPreview and SubsiteID. @param type $link @return type
entailment
public function assemble(array $config, ContainerBuilder $container) { $this->addTask( 'bldr_watch.watch', 'Bldr\Block\Watch\Task\WatchTask', [ new Reference('bldr.registry.job'), [ 'profiles' => $container->getParameter...
{@inheritDoc}
entailment
protected function assemble() { $assembled = $this->command; foreach ($this->arguments as $key => $value) { if (is_int($key) && false === strpos((string) $key, '-')) { $assembled .= ' '.escapeshellarg($value); continue; } ...
Assemble command and arguments. @return string
entailment
public function execute(Control $control, Context $context) { $context->command = $this->assemble(); $context->outputTail = exec(sprintf('(%s)2>&1', $context->command), $outputLines, $returnValue); $context->outputString = implode(PHP_EOL, $outputLines); $context->outputLin...
{@inheritdoc}
entailment
public function assemble(array $config, SymfonyContainerBuilder $container) { $this->addTaskOptions($config, $this->originalConfiguration); $this->setParameter('name', $config['name']); $this->setParameter('description', $config['description']); $this->setParameter('profiles', $conf...
{@inheritDoc}
entailment
public function augmentSQL(SQLQuery &$query) { if (Subsite::$disable_subsite_filter) { return; } // Filter by subsite $ids = array((int) Subsite::currentSubsiteID()); // If configured to treat subsite 0 as global, include ID 0. if (Config::inst()->get('L...
Update any requests to limit the results to the current site
entailment
public function process(ContainerBuilder $container) { $useLoadingSearchResultExtractor = $container->getParameter( 'netgen_ez_platform_search_extra.use_loading_search_result_extractor' ); if ($useLoadingSearchResultExtractor === true) { return; } $s...
{@inheritdoc} @throws \Exception
entailment
public static function createEmbeddedShell(SessionInterface $session) { $container = new Container(self::MODE_EMBEDDED_SHELL); $container->get('phpcr.session_manager')->setSession(new PhpcrSession($session)); $application = $container->get('application'); return new Shell($applicati...
Create a new embedded shell. @param SessionInterface $session @return Shell
entailment
public static function createEmbeddedApplication(SessionInterface $session) { $container = new Container(self::MODE_EMBEDDED_COMMAND); $container->get('phpcr.session_manager')->setSession(new PhpcrSession($session)); $application = $container->get('application'); return $application...
Create a new (non-interactive) embedded application (e.g. for running single commands). @param SessionInterface $session @return EmbeddedApplication
entailment
public function handle(RemoveFromCart $command) { $cart = $this->carts->getById(new CartId($command->cartId())); $cart->remove(new SKU($command->sku())); }
@param RemoveFromCart $command @throws \Exception
entailment
public function map(string $schema, Table $table, string $name, FieldDefinition $definition) { foreach ($this->mapping as $mapping) { if ($mapping->maps($definition->type())) { $mapping->map($schema, $table, $name, $definition); return; } } ...
@param string $schema @param Table $table @param string $name @param FieldDefinition $definition @throws DoctrineStorageException
entailment
private function replaceColumnOperands($functionMap, RowInterface $row) { foreach ($this->arguments as $key => $value) { if ($value instanceof ColumnOperand) { $this->arguments[$key] = $row->getNode($value->getSelectorName())->getPropertyValue($value->getPropertyName()); ...
Replace the Operand objects with their evaluations. @param array Array of function closures @param RowInterface $row
entailment
public function execute($functionMap, $row) { $this->replaceColumnOperands($functionMap, $row); $functionName = $this->getFunctionName(); if (!isset($functionMap[$functionName])) { throw new InvalidQueryException(sprintf('Unknown function "%s", known functions are "%s"', ...
Evaluate the result of the function. @param array Array of function closures @param RowInterface $row
entailment
public function validateScalarArray($array) { if (!is_array($array)) { throw new \InvalidArgumentException(sprintf( 'Expected array value, got: %s', var_export($array, true) )); } foreach ($array as $key => $value) { if (fa...
Used as callback for closure functions. @param array Array of values which must be scalars @throws InvalidArgumentException
entailment
public function register() { $adapter = $this->getContainer()->get(AdapterInterface::class); $this->getContainer()->share('repo.user', new UsersRepository($adapter)); $this->getContainer()->share('repo.media', new MediaRepository($adapter)); $this->getContainer()->share('repo.comment...
Use the register method to register items with the container via the protected ``$this->container`` property or the ``getContainer`` method from the ``ContainerAwareTrait``. @return void
entailment
public function register($name, Closure $callback) { $this->checkCallbackName($name); $this->callbacks[$name] = $callback; return $this; }
Register a breadcrumb domain. @param string $name @param \Closure $callback @return self
entailment
public function render($name = null, ...$params) { return new HtmlString( view($this->getView(), [ 'breadcrumbs' => $this->generate($name, $params) ])->render() ); }
Render breadcrumbs items. @param string|null $name @param array $params @return \Illuminate\Support\HtmlString
entailment
public function generate($name, ...$params) { return (new Builder($this->callbacks)) ->call($name, $params) ->toArray(); }
Generate the breadcrumbs. @param string $name @param array $params @return array
entailment
private function checkTemplate($template) { if ( ! is_string($template)) { $type = gettype($template); throw new Exceptions\InvalidTypeException( "The default template name must be a string, $type given." ); } $template = strtolower(trim($...
Check Template. @param string $template @throws Exceptions\InvalidTemplateException @throws Exceptions\InvalidTypeException
entailment
private function checkCallbackName(&$name) { if ( ! is_string($name)) { $type = gettype($name); throw new Exceptions\InvalidTypeException( "The callback name value must be a string, $type given." ); } $name = strtolower(trim($name)); ...
Check Name. @param string $name @throws Exceptions\InvalidTypeException
entailment
public function getById(string $cartId): Checkout { $qb = $this->connection->createQueryBuilder(); $qb->select( 'id', 'billing_address_name', 'billing_address_street', 'billing_address_post_code', 'billing_address_city', 'billing_address_country_iso2code', 'shipping_address_n...
@param string $cartId @throws QueryException @return Checkout
entailment
private function getItemBySku(string $sku, int $quantity): CartItem { $qb = $this->connection->createQueryBuilder(); $qb->select('*') ->from('dumplie_inventory_product') ->where('sku = :sku') ->setParameter('sku', $sku); $itemData = $this->connection->fet...
@param string $sku @param int $quantity @return CartItem @throws QueryException
entailment
public function doesCartWithIdExist(string $cartId): bool { $qb = $this->connection->createQueryBuilder(); $qb->select('COUNT(*)') ->from('dumplie_customer_cart') ->where('id = :id') ->setParameter('id', $cartId) ->getSQL(); return (bool)$this...
@param string $cartId @return bool
entailment
public function index() { $s = CalendarConfig::subpackage_settings('pagetypes'); $indexSetting = $s['calendarpage']['index']; if ($indexSetting == 'eventlist') { //return $this->returnTemplate(); return $this; } elseif ($indexSetting == 'calendarview') { ...
Coming events
entailment
public function calendarview() { $s = CalendarConfig::subpackage_settings('pagetypes'); //Debug::dump($s); if (isset($s['calendarpage']['calendarview']) && $s['calendarpage']['calendarview']) { Requirements::javascript('calendar/thirdparty/fullcalendar/2.9.1/fullcalendar/lib/m...
Calendar View Renders the fullcalendar
entailment
public function detail($req) { $event = Event::get()->byID($req->param('ID')); if (!$event) { return $this->httpError(404); } return array( 'Event' => $event, ); }
Displays details of an event @param $req @return array
entailment
public function Events() { $action = $this->request->param('Action'); //Debug::dump($this->request->params()); //Normal & Registerable events $s = CalendarConfig::subpackage_settings('pagetypes'); $indexSetting = $s['calendarpage']['index']; if ($action == 'eventregi...
Event list for "eventlist" mode @return type
entailment
public function CurrentCalendar() { $url = Convert::raw2url($this->request->param('ID')); $cal = PublicCalendar::get() ->filter('URLSegment', $url) ->First(); return $cal; }
Renders the current calendar, if a calenar link has been supplied via the url
entailment
public function run(OutputInterface $output) { foreach ($this->resolveFiles() as $file) { if ($this->fileSystem->exists($file)) { if (!$this->continueOnError()) { throw new TaskRuntimeException($this->getName(), "File `$file` already exist."); ...
{@inheritdoc}
entailment
public function message($message, $type = 'alert') { $messages = []; if(!empty($message)) { // It loooked if exist any old messages if (!empty(session('noty.messages'))) { $messages = session('noty.messages'); } // Add last new messa...
Flash a message. @param string $message @param string $type @return $this
entailment
public function register() { $this->mergeConfigFrom(__DIR__.'/../../config/laravel-noty.php', 'laravel-noty'); $this->app->bind(NotySessionStore::class); $this->app->singleton('noty', function () { return $this->app->make(NotyNotifier::class); }); }
Register bindings in the container. @return void
entailment
public function boot() { collect(glob(__DIR__ . '/Database/Schema/macros/*.php')) ->each(function($path) { require $path; }); /* A little hack to have Builder::hasMacro */ \Illuminate\Database\Eloquent\Builder::macro('hasMacro', function($name) { ...
Bootstrap the application services.
entailment
public function hasDescriptor($descriptor, $value = null) { $this->loadDescriptors(); $exists = array_key_exists($descriptor, $this->descriptors); if (false === $exists) { return false; } if (null === $value) { return true; } $descr...
Return true if the sessionManager supports the given descriptor which relates to a descriptor key. @param string $descriptor
entailment
public function getMedia($id = 'self', $count = null, $minId = null, $maxId = null) { $params = ['query' => [ 'count' => $count, 'min_id' => $minId, 'max_id' => $maxId, ]]; return $this->client->request( 'GET', "users/$id/med...
Get the most recent media published by a user. @param string $id The ID of the user. Default is ``self`` @param int|null $count Count of media to return @param int|null $minId Return media later than this min_id @param int|null $maxId Return media earlier than this max_id @return Response @link https://inst...
entailment
public function getLikedMedia($count = null, $maxLikeId = null) { $params = ['query' => [ 'count' => $count, 'max_like_id' => $maxLikeId ]]; return $this->client->request( 'GET', 'users/self/media/liked', $params ); ...
Get the list of recent media liked by the owner of the access token. @param int|null $count Count of media to return @param int|null $maxLikeId Return media liked before this id @return Response @link https://instagram.com/developer/endpoints/users/#get_users_feed_liked
entailment
public function search($query, $count = null) { $params = ['query' => [ 'q' => $query, 'count' => $count, ]]; return $this->client->request( 'GET', 'users/search', $params ); }
Get a list of users matching the query. @param string $query A query string to search for @param int|null $count Number of users to return @return Response @link https://instagram.com/developer/endpoints/users/#get_users_search
entailment
public function find($username) { $response = $this->search($username); foreach ($response->get() as $user) { if ($username === $user['username']) { return $this->get($user['id']); } } return null; }
Searches for and returns a single user's information. If no results are found, ``null`` is returned. @param string $username A username to search for @return Response|null
entailment
protected function bindDefaultTriggers() { $this->handlers[self::EVENT_INIT] = $this->fluentCallback([$this, 'handleInit']); $this->handlers[self::EVENT_FORK] = $this->fluentCallback([$this, 'handleFork']); $this->handlers[self::EVENT_START] = $this->fluentCallback([$this, 'handleStart'...
Binds some callbacks as default triggers.
entailment
public function bind($event, callable $handler) { if (in_array($event, [self::EVENT_INIT, self::EVENT_FORK, self::EVENT_START])) { throw new InvalidArgumentException('You can not bind a callback for this event'); } parent::bind($event, $handler); }
{@inheritdoc} @throws InvalidArgumentException When event binding is forbidden.
entailment
public function handleInit(Control $control, Context $context) { if (! $context->pidfile instanceof Pidfile) { $context->pidfile = new Pidfile($control, $this->getOption('name'), $this->getOption('lock_dir')); } $context->isRunning = $context->pidfile->isActive(); $contex...
Default trigger for EVENT_INIT. @param Control $control @param Context $context
entailment
public function handleStart(Control $control, Context $context) { if (! $context->pidfile instanceof Pidfile) { throw new LogicException('Pidfile is not defined'); } // Activates the circular reference collector gc_enable(); // Callback for handle when process i...
Default trigger for EVENT_START. - Activates the circular reference collector - Detach session - Reset umask - Update work directory - Close file descriptors - Define process owner, if any - Define process group, if any - Create new file descriptors - Create pidfile - Define pidfile cleanup @param Control $control @p...
entailment
public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('notify'); $rootNode ->children() ->arrayNode('smtp') ->children() ->scalarNode('host')->isRequired()->end() ...
{@inheritDoc}
entailment
public function onBlock(BlockEvent $event) { $identifier = $event->getSetting('id', null); if (null === $identifier) { return; } $block = new Block(); $block->setId(uniqid()); $block->setSettings($event->getSettings()); $block->setType($this->blo...
Add blocks services to event. @param BlockEvent $event
entailment
public function addParameter($name, $required = false, $description = '', $default = null) { $this->parameters[$name] = [ 'name' => $name, 'required' => $required, 'description' => $description, 'default' => $default, 'value' =>...
Adds a parameter to the definition of the Task @param string $name Name of the task parameter @param bool $required If true, task parameter is required @param string $description Description of the task parameter @param mixed $default Default value of the task parameter, null by default @return mixed
entailment
public function getParameters() { $parameters = []; foreach ($this->parameters as $name => $parameter) { $parameters[$name] = $this->getParameter($name); } return $parameters; }
{@inheritDoc}
entailment
public function getParameter($name, $validate = true) { if ($validate && !array_key_exists($name, $this->parameters)) { throw new ParameterNotFoundException($name); } $param = $this->parameters[$name]; $value = $param['value']; if (null === $value) { ...
{@inheritdoc} @throws ParameterNotFoundException @throws RequiredParameterException
entailment
public function hasParameter($name) { if (array_key_exists($name, $this->parameters)) { if (null !== $this->parameters[$name]['value']) { return true; } } return false; }
Returns true if the Task has a parameter with the given name, and the value is not null. Returns false otherwise. @param string $name @return bool
entailment
public function setParameter($name, $value) { if (!array_key_exists($name, $this->parameters)) { $this->addParameter($name, false, '', null); } $this->parameters[$name]['value'] = $value; }
{@inheritdoc}
entailment
public function validate() { foreach ($this->parameters as $name => $parameter) { if (null === $parameter['value']) { if (true === $parameter['required']) { throw new RequiredParameterException($name); } } } return ...
{@inheritdoc}
entailment
private function replaceTokens($option) { if (is_array($option)) { $tokenizedOptions = []; foreach ($option as $key => $opt) { $tokenizedOptions[$key] = $this->replaceTokens($opt); } return $tokenizedOptions; } return preg_rep...
Tokenize the given option, if it is a string. @param mixed $option @return mixed
entailment
public function getPath(UriInterface $uri) { $path = trim($uri->getPath(), '/'); $parts = explode('/', $path); if ($parts[0] === 'v'.Client::API_VERSION) { unset($parts[0]); } return '/'.implode('/', $parts); }
Gets the path from a ``UriInterface`` instance after removing the version prefix. @param UriInterface $uri @return string
entailment
public function getQueryParams(UriInterface $uri, $exclude = ['sig'], $params = []) { parse_str($uri->getQuery(), $params); foreach ($exclude as $excludedParam) { if (array_key_exists($excludedParam, $params)) { unset($params[$excludedParam]); } } ...
Gets the query parameters as an array from a ``UriInterface`` instance. @param UriInterface $uri @param array $exclude @param array $params @return array
entailment
public function url() { if ($this->urlName) return $this->urlName; if ($this->objectClass) return $this->objectClass->url($this); return null; }
Returns the API url where you can receive this object. @return null|string
entailment
public function refresh() { $response = $this->api->get($this->url()); $this->data = (array) $response->data; return $this; }
Makes a GET request and refreshes the local data with up-to-date info. @return $this
entailment
public function update($data) { $response = $this->api->put($this->url(), $data); $this->data = (array) $response->data; return $this; }
Updates the API object with $data. @param $data @return $this
entailment
public static function init($path) { pake_mkdirs($path); pake_sh(escapeshellarg(pake_which('hg')).' init -q '.escapeshellarg($path)); return new pakeMercurial($path); }
new mercurial-repo
entailment