_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q27800
Pupiq.getColors
train
function getColors(){ $adf = new ApiDataFetcher(PUPIQ_API_URL); try { $colors = $adf->get("image_colors/detail",array( "url" => $this->getUrl(), "auth_token" => $this->getAuthToken(), ),array( "acceptable_error_codes" => array("404","403"), "cache" => 60 * 60 * 24 * 30, // 30 days )); }c...
php
{ "resource": "" }
q27801
Pupiq.getImageId
train
function getImageId(){ $ary = explode('/',$this->_image_id); // "75c/75c1/" -> ["75c","75c1",""] if(isset($ary[1])){ return (int)hexdec($ary[1]); } }
php
{ "resource": "" }
q27802
TypeRegistry.register
train
public function register(TypeInterface $type) { if (isset($this->types[$name = $type->getName()])) { throw new \RuntimeException("Slide type '$name' is already registered."); } $this->types[$name] = $type; return $this; }
php
{ "resource": "" }
q27803
Path.format
train
public static function format($string, $format, $separator = '/') { // Trim $string = trim($string, $separator); // Empty path case if ($string === '') { if ($format == self::FORMAT_BOTH_DELIMITERS) { return $separator; } else { return $string; } } // Add delimiters if ($format & s...
php
{ "resource": "" }
q27804
Path.getBasePath
train
public function getBasePath($offset = 0, $format = self::FORMAT_NO_DELIMITERS) { $basePathList = $this->basePathParts; if ($offset > 0) { $basePathList = array_slice($basePathList, 0, -$offset); } $parts = new Path('', $this->separator); foreach ($basePathList as $path) { $parts->append($path)...
php
{ "resource": "" }
q27805
InitCommand.initConfig
train
protected function initConfig($file) { if(file_exists($this->dir.'/'.$file)) { if(!$this->confirm('Do you want to override "'.$file.'"?')) return; } $config = file_get_contents(__DIR__.'/stubs/'.$file.'.stub'); $key = \Asgard\Common\Tools::randStr(10); $config = str_replace('_KEY_', $key, $config); ...
php
{ "resource": "" }
q27806
SmartyAssetsResolver.resolveAssetSourcePath
train
public function resolveAssetSourcePath($source, $templateName, $fileName, ParserInterface $parserInterface) { $tpl = $parserInterface->getTemplateDefinition(false); return $this->resolveAssetSourcePathAndTemplate( $source, $templateName, $fileName, $p...
php
{ "resource": "" }
q27807
SmartyAssetsResolver.resolveAssetSourcePathAndTemplate
train
public function resolveAssetSourcePathAndTemplate( $source, $templateName, $fileName, ParserInterface $parserInterface, TemplateDefinition &$templateDefinition ) { // A simple cache for the path list, to gain some performances static $cache = []; // T...
php
{ "resource": "" }
q27808
SmartyAssetsResolver.getPossibleAssetSources
train
protected function getPossibleAssetSources($directories, $templateName, $source, &$pathList) { if ($source !== ParserInterface::TEMPLATE_ASSETS_KEY) { // We're in a module. // First look into the current template in the right scope : frontOffice, backOffice, ... // templ...
php
{ "resource": "" }
q27809
AnnotationReader.fetchRoutes
train
public function fetchRoutes($class) { $routes = []; $reader = new \Doctrine\Common\Annotations\SimpleAnnotationReader(); $reader->addNamespace('Asgard\Http\Annotation'); if($this->cache) { $reader = new \Doctrine\Common\Annotations\CachedReader( $reader, $this->cache, $this->debug ); } $...
php
{ "resource": "" }
q27810
AnnotationReader.setCache
train
public function setCache(\Doctrine\Common\Cache\Cache $cache) { $this->cache = $cache; return $this; }
php
{ "resource": "" }
q27811
AbstractRequireTag.checkOptionalPath
train
protected function checkOptionalPath($assetPath) { if (0 === strpos($assetPath, '?')) { $assetPath = ltrim($assetPath, '?'); $this->setOptional(true); } return $assetPath; }
php
{ "resource": "" }
q27812
Entity.lock
train
protected function lock($name) { if (! array_key_exists($name, $this->locks)) { $this->locks[$name] = true; return true; } return false; }
php
{ "resource": "" }
q27813
Entity.unlock
train
protected function unlock($name) { if (! array_key_exists($name, $this->locks)) { return false; } unset($this->locks[$name]); return true; }
php
{ "resource": "" }
q27814
Entity.equals
train
public function equals(Entity $entity = null) { if ($entity === null) { return false; } // Equals if matches if ($entity === $this) { return true; } $id = $this->getId(); if ( ! empty($id) && $entity->getId() === $id) { return true; } return false; }
php
{ "resource": "" }
q27815
Entity.collectIds
train
public static function collectIds($entities) { $ids = array(); foreach ($entities as $entity) { $ids[] = $entity->getId(); } return $ids; }
php
{ "resource": "" }
q27816
Entity.addUnique
train
protected function addUnique(Collection $collection, Entity $newItem, $uniqueField = null) { if ($collection->contains($newItem)) { return false; } if (is_null($uniqueField)) { $collection->add($newItem); } else { $indexBy = $newItem->getProperty($uniqueField); if ($collection->offsetExists($inde...
php
{ "resource": "" }
q27817
Entity.generateId
train
public static function generateId($className = '') { // TODO: on 32bit systems this might generate low precision hashes due to float number usage in the base_convert function $timeParts = explode(' ', microtime(false)); $timeParts[0] = substr($timeParts[0], 2, 3); $time = ((int) $timeParts[1] - 1324027985) . $...
php
{ "resource": "" }
q27818
Entity.writeOnce
train
protected function writeOnce(&$property, $value) { $sourceEntity = get_class($this); if (empty($value)) { $this->unlockAll(); throw new \RuntimeException("Second argument sent to method $sourceEntity::writeOnce() cannot be empty"); } if ( ! is_object($value)) { $this->unlockAll(); throw new \Runtim...
php
{ "resource": "" }
q27819
ResourceRepository.listCurrencies
train
public function listCurrencies() { if (is_null($this->currencyCodes)) { $directory = new \RecursiveDirectoryIterator($this->getCurrencyResourceDirectory()); foreach ($directory as $item) { if (preg_match('#^...\.json$#', $item->getFilename())) { $this->currencyCodes[] = substr($item->g...
php
{ "resource": "" }
q27820
ResourceRepository.loadCurrency
train
public function loadCurrency($currencyCode) { $filePath = $this->getCurrencyResourceDirectory() . "/$currencyCode.json"; if (is_readable($filePath)) { return $this->createCurrencyFromJson(file_get_contents($filePath)); } else { return null; } }
php
{ "resource": "" }
q27821
ResourceRepository.createCurrencyFromJson
train
protected function createCurrencyFromJson($json) { $currency_data = json_decode($json); $currency = new Currency(); $currency->setCurrencyCode($currency_data->ISO4217Code); if (isset($currency_data->ISO4217Number)) { $currency->setCurrencyNumber($currency_data->ISO4217Number); } if (isset...
php
{ "resource": "" }
q27822
Flot.convert
train
public function convert(array $data, $orientation = 'vertical', $datetime = false) { $chartData = array(); // if only one series passed in (single-dimensional array), wrap in array for the series looping if (!$this->hasMultipleSeries($data)) { $data = array($data); } ...
php
{ "resource": "" }
q27823
PagesTemplateController.templatesListAction
train
public function templatesListAction() { $localeId = $this->getCurrentLocale() ->getId(); $templateLocalizations = $this->getEntityManager() ->getRepository(TemplateLocalization::CN()) ->findBy(array('locale' => $localeId), array('title' => 'asc')); /* @var $templateLocalizations TemplateLocalizatio...
php
{ "resource": "" }
q27824
PagesTemplateController.deleteAction
train
public function deleteAction() { $page = $this->getPageLocalization() ->getMaster(); $entityManager = $this->getEntityManager(); $count = (int) $entityManager->createQuery(sprintf('SELECT COUNT(p.id) FROM %s p WHERE p.template = ?0', PageLocalization::CN())) ->setParameters(array($page->getId())) -...
php
{ "resource": "" }
q27825
PagesTemplateController.saveAction
train
public function saveAction() { $this->isPostRequest(); $this->checkLock(); $this->saveLocalizationCommonAction(); $this->getEntityManager() ->flush($this->getPageLocalization()); return new SupraJsonResponse(); }
php
{ "resource": "" }
q27826
SymfonyUrlGenerator.getUrlPathFromConfig
train
protected function getUrlPathFromConfig($urlConfig) { $urlPath = parent::getUrlPathFromConfig($urlConfig); try { $path = is_array($urlPath) ? $urlPath[0] : $urlPath; $arguments = ( is_array($urlPath) && isset($...
php
{ "resource": "" }
q27827
Manager.getClient
train
public function getClient($path = '/solr') { $options = $this->options; $options = [ 'secure' => $options->isSecure(), 'hostname' => $options->getHostname(), 'port' => $options->getPort(), 'path' => $path, 'login' => $options->getUsername()...
php
{ "resource": "" }
q27828
AbstractSupraPackage.getName
train
public function getName() { $class = get_class($this); $class = explode('\\', $class); $class = $class[count($class) - 1]; $class = str_replace(array('Supra', 'Package'), '', $class); $inflector = new Inflector(); $name = $inflector->tableize($class); return $name; }
php
{ "resource": "" }
q27829
Collection.map
train
public function map(callable $callable) { $keys = array_keys($this->items); $results = array_map($callable, $this->items, $keys); return new self($results); }
php
{ "resource": "" }
q27830
Collection.filter
train
public function filter(callable $callable) { $results = []; foreach ($this->items as $key => $item) { if ($callable($item, $key)) { $results[] = $item; } } return new self($results); }
php
{ "resource": "" }
q27831
Collection.sortByKey
train
public function sortByKey(callable $callback = null) { $items = $this->items; $callback ? uksort($items, $callback) : ksort($items); return new static($items); }
php
{ "resource": "" }
q27832
Collection.itemSet
train
private function itemSet($value, $key = null) { if (is_null($key)) { $this->items[] = $value; } else { $this->items[$key] = $value; } }
php
{ "resource": "" }
q27833
ConcentrationMass.fromMassAndVolume
train
public static function fromMassAndVolume(Mass $mass, Volume $volume) { $grams = $mass->convertTo(UnitMass::grams()); $liters = $volume->convertTo(UnitVolume::liters()); $gramsPerLiter = $grams->value() / $liters->value(); return new static($gramsPerLiter, UnitConcentrationMass::gramsPerLiter()); }
php
{ "resource": "" }
q27834
DoctrineExtension.minifyQuery
train
public function minifyQuery($query) { $result = ''; $keywords = array(); $required = 1; // Check if we can match the query against any of the major types switch (true) { case stripos($query, 'SELECT') !== false: $keywords = array('SELECT', 'FROM',...
php
{ "resource": "" }
q27835
DoctrineExtension.escapeFunction
train
public static function escapeFunction($parameter) { $result = $parameter; switch (true) { case is_string($result) : $result = "'" . addslashes($result) . "'"; break; case is_array($result) : foreach ($result as &$value) { ...
php
{ "resource": "" }
q27836
NotificationManager.handle
train
protected function handle(NotificationInterface $notification, NotificationHandlerInterface $handler): bool { if (! $handler->supports($notification)) { return false; } $cloned = clone $notification; $event = new NotifyEvent($cloned, $handler); $this->eventDispa...
php
{ "resource": "" }
q27837
PDOStatement.setParameterMarkerNames
train
public function setParameterMarkerNames ($raw_query_string, array $named_parameter_markers) { if ($this->named_parameter_markers !== null) { throw new Exception\LogicException('Parameter markers can be set only at the time of building the statement.'); } $this->raw_query_string = $r...
php
{ "resource": "" }
q27838
CInterface.getSessionDetails
train
public function getSessionDetails($path) { global $phpbb_root_path, $phpEx, $user, $db, $config, $cache, $template, $auth; // Enable to work even if forum is not available if (!is_file("$path/webb.config")) { return [ 'is_anonymous' => "No one", ...
php
{ "resource": "" }
q27839
LinkReferencedElement.getElementTitle
train
public function getElementTitle() { throw new \Exception('Dont use me bro.'); $title = null; switch ($this->resource) { case self::RESOURCE_PAGE: $pageData = $this->getPage(); /* @var $pageData Localization */ if ( ! is_null($pageData)) { $title = $pageData->getTitle(); } break; ...
php
{ "resource": "" }
q27840
LinkReferencedElement.setPageLocalization
train
public function setPageLocalization(PageLocalization $pageLocalization) { $this->pageLocalization = $pageLocalization; $this->pageId = $pageLocalization->getMaster()->getId(); }
php
{ "resource": "" }
q27841
LinkReferencedElement.getPageFullPath
train
private function getPageFullPath(Localization $pageLocalization) { throw new \Exception('Dont use me bro.'); if ( ! $pageLocalization instanceof PageLocalization) { return null; } $path = $pageLocalization->getPath(); $url = null; if ( ! is_null($path) && ! $path instanceof NullPath) { $url = $p...
php
{ "resource": "" }
q27842
LinkReferencedElement.getUrl
train
public function getUrl() { throw new \Exception('Dont use me bro.'); $url = null; switch ($this->getResource()) { case self::RESOURCE_PAGE: $pageData = $this->getPage(); if ( ! is_null($pageData)) { $url = $this->getPageFullPath($pageData); } break; case self::RESOURCE_FILE: $...
php
{ "resource": "" }
q27843
LinkReferencedElement.getPageLocalization
train
public function getPageLocalization() { throw new \Exception('Dont use me bro.'); if (empty($this->pageId)) { return; } if ( ! is_null($this->pageLocalization)) { return $this->pageLocalization; } $em = ObjectRepository::getEntityManager($this); $pageData = null; $localizationEntity = Localiz...
php
{ "resource": "" }
q27844
CalendarManager.parseDateTimes
train
private function parseDateTimes($datetimes) { foreach ($datetimes as &$datetime) { $datetime->date_time = new \DateTime($datetime->date_time); } return $datetimes; }
php
{ "resource": "" }
q27845
CalendarManager.prepareDateTimes
train
private function prepareDateTimes($datetimes) { $parsedDateTimes = $this->parseDateTimes($datetimes); $sortedDateTimes = array(); foreach ($parsedDateTimes as $parsedDateTime) { $hour = date('G', $parsedDateTime->date_time->getTimestamp()); if (!isset($sortedDateTimes...
php
{ "resource": "" }
q27846
CalendarManager.findCalendar
train
private function findCalendar($calendarId, $calendars) { if (isset($calendars[$calendarId])) { return $calendars[$calendarId]; } else { throw new \Exception( $this->translator->trans( 'services.calendar_manager.calendar_in_block_not_found',...
php
{ "resource": "" }
q27847
CalendarManager.sortCalendars
train
private function sortCalendars($calendars) { $calendarsSorted = array(); foreach ($calendars as $calendar) { $calendarsSorted[$calendar->id] = $calendar; $calendarsSorted[$calendar->id]->week_pattern = (array) $calendarsSorted[$calendar->id]->week_pattern; } ...
php
{ "resource": "" }
q27848
CalendarManager.generateExceptionsValues
train
private function generateExceptionsValues($navitiaExceptions) { $exceptions = array(); foreach ($navitiaExceptions as $exception) { $date = new \DateTime($exception->date); $exception->value = $this->translator->trans( 'global.exceptions.' . strtolower($exce...
php
{ "resource": "" }
q27849
CalendarManager.addSchedulesToCalendar
train
private function addSchedulesToCalendar($calendar, $schedules) { $calendar->schedules = $schedules; $calendar->schedules->date_times = $this->prepareDateTimes($calendar->schedules->date_times); return $calendar; }
php
{ "resource": "" }
q27850
CalendarManager.generateAdditionalInformations
train
private function generateAdditionalInformations($additionalInformationsId) { $additionalInformations = null; if (!empty($additionalInformationsId) && !in_array($additionalInformationsId, $this->additionalInformationsExcluded)) { $additionalInformations = $this->translator->trans( ...
php
{ "resource": "" }
q27851
CalendarManager.getCalendarsForStopPointAndTimetable
train
public function getCalendarsForStopPointAndTimetable( $externalCoverageId, $timetable, $stopPointInstance ) { $notesComputed = array(); $calendarsSorted = array(); // indicates whether to aggregate or dispatch notes $layout = $timetable->getLineConfig()->getLa...
php
{ "resource": "" }
q27852
CalendarManager.getCalendarsForRoute
train
public function getCalendarsForRoute($externalCoverageId, $externalRouteId, \DateTime $startDate, \DateTime $endDate) { $calendarsData = $this->navitia->getRouteCalendars($externalCoverageId, $externalRouteId, $startDate, $endDate); $calendarsSorted = array(); if (isset($calendarsData->calen...
php
{ "resource": "" }
q27853
BusinessPerimeterManager.addUserToPerimeter
train
public function addUserToPerimeter(UserInterface $user, BusinessPerimeterInterface $perimeter) { $this->perimeterManager->addUserToPerimeter($user->getId(), $perimeter->getId()); }
php
{ "resource": "" }
q27854
BusinessPerimeterManager.getPerimeters
train
public function getPerimeters() { if (null === $this->perimeters) { $perimeters = array(); foreach ($this->perimeterManager->findAll() as $network) { $perimeter = new BusinessPerimeter($network->getExternalPerimeterId()); $perimeter->setId($network->ge...
php
{ "resource": "" }
q27855
BusinessPerimeterManager.getUserPerimeters
train
public function getUserPerimeters(UserInterface $user) { $userPerimeters = array(); foreach ($this->perimeterManager->findUserPerimeters($user) as $network) { foreach ($this->getPerimeters() as $perimeter) { if ($perimeter->getId() == $network['id'] && $perimeter->getName...
php
{ "resource": "" }
q27856
ElasticSearchTrait.getAllES
train
public function getAllES(string $sortBy = "", string $sortType = "ASC") { $data = $this->getESItems(10000, 0, $sortBy, $sortType); return $data['items']; }
php
{ "resource": "" }
q27857
ElasticSearchTrait.paginateES
train
public function paginateES(int $size = 20, string $sortBy = "", string $sortType = "ASC", int $page = null) : LengthAwarePaginator { if(!$page) { $page = (Input::get("page") ? Input::get("page") : 1); } $from = (($page * $size) - $size); $data = $this->getESItems($size,...
php
{ "resource": "" }
q27858
ElasticSearchTrait.getESItems
train
private function getESItems($size, $from, string $sortBy = "", string $sortType = "ASC") { $query = [ "match_all" => (object) [] ]; if($this->elasticQuery) { $query = [ "bool" => [ "must" => $this->elasticQuery ] ...
php
{ "resource": "" }
q27859
ElasticSearchTrait.whereMultiMatch
train
public function whereMultiMatch(string $query, array $fields, $fuzziness = "auto") { $param = [ "multi_match" => [ "query" => $query, "fields" => $fields, "fuzziness" => $fuzziness ] ]; $this->elasticQuery[] = $param; ...
php
{ "resource": "" }
q27860
ElasticSearchTrait.whereMatch
train
public function whereMatch(string $field, string $query, $operator = "or", $fuzziness = 0) { $param = [ "match" => [ $field => [ "query" => $query, "operator" => $operator, "fuzziness" => $fuzziness ] ...
php
{ "resource": "" }
q27861
ElasticSearchTrait.whereTerms
train
public function whereTerms(string $field, array $query) { $param = [ "terms" => [ $field => $query ] ]; $this->elasticQuery[] = $param; return $this; }
php
{ "resource": "" }
q27862
ElasticSearchTrait.whereTerm
train
public function whereTerm(string $field, $term) { $param = [ "term" => [ $field => $term ] ]; $this->elasticQuery[] = $param; return $this; }
php
{ "resource": "" }
q27863
ElasticSearchTrait.whereRange
train
public function whereRange(string $field, $gt = null, $lt = null, $format = null, $gtConfig = "gte", $ltConfig = "lte") { if($gt && $lt) { $field = []; if($gt) { $field[$gtConfig] = $gt; } if($lt) { $field[$ltConfig] = $lt; ...
php
{ "resource": "" }
q27864
ElasticSearchTrait.toElequent
train
private function toElequent(array $attributes) { $obj = new static(); $casts = $obj->casts; $obj->casts = []; $obj->setRawAttributes($attributes); $obj->casts = $casts; return $obj; }
php
{ "resource": "" }
q27865
Requirements.check
train
public function check(Command $console) { $this->console = $console; $this->console->comment("\nChecking system requirements"); $this->process = new Process($this->console); $this->versionCheck(); $this->extensionCheck(); $this->hasDatabaseDriver(); $this->d...
php
{ "resource": "" }
q27866
Requirements.hasDatabaseDriver
train
private function hasDatabaseDriver() { if (!count($this->getDatabaseDrivers())) { $this->console->error( 'At least 1 PDO driver is required. Either sqlite, mysql or pgsql, check your php.ini file' ); $this->errors = true; } return false; ...
php
{ "resource": "" }
q27867
Requirements.disabledFunctionCheck
train
private function disabledFunctionCheck() { $functions = [ 'exec' ]; // Functions needed by symfony process foreach($functions as $function){ if (!function_exists($function)) { $this->console->error('Function "'.$function.'" is required. Is it ...
php
{ "resource": "" }
q27868
Requirements.requiredSystemCommands
train
private function requiredSystemCommands() { // todo fix command existence in windows os return true; // Programs needed in $PATH $required_commands = ['git', 'rsync','php', 'composer']; $missing = []; foreach ($required_commands as $command) { $this->p...
php
{ "resource": "" }
q27869
Requirements.nodeJsCommand
train
private function nodeJsCommand() { // todo check nodejs exists in windows os return true; $found = false; foreach (['node', 'nodejs'] as $command) { $this->process->setCommandLine('which ' . $command); $this->process->setTimeout(null); $this->proc...
php
{ "resource": "" }
q27870
Requirements.checkPermissions
train
private function checkPermissions() { foreach ($this->writableDirectories as $path) { if (!$this->filesystem->isWritable(base_path($path))) { $this->console->error($path . ' is not writable'); $this->errors = true; } } }
php
{ "resource": "" }
q27871
InstallCommand.exportConfig
train
private function exportConfig($connection) { if (!config('datasets.'.$this->argument('dataset').'.connection') || config('datasets.'.$this->argument('dataset').'.connection') !== $connection) { config(['datasets.'.$this->argument('dataset').'.connection' => $connection]); $config_con...
php
{ "resource": "" }
q27872
CharsetStream.write
train
public function write($string) { $converted = $this->converter->convert($string, $this->stringCharset, $this->streamCharset); $written = $this->converter->getLength($converted, $this->streamCharset); $this->position += $written; return $this->stream->write($converted); }
php
{ "resource": "" }
q27873
TranslatableTrait.getAttribute
train
public function getAttribute($key) { //set default language if(!$this->_defaultTranslateLanguage) { $this->setDefaultTranslateLanguage(); } // In case we just need the translation for current property if(!$this->getTranslateLanguage()) { $this->transl...
php
{ "resource": "" }
q27874
TranslatableTrait.setDefaultTranslateLanguage
train
public function setDefaultTranslateLanguage($languageSlug = '') { if(!$languageSlug) { $languageSlug = App::getLocale(); } $this->_defaultTranslateLanguage = $languageSlug; return $this; }
php
{ "resource": "" }
q27875
TranslatableTrait.isTranslatable
train
public function isTranslatable($value, $key) { // in case cast is not used, we need to manually convert the value to object if(!is_object($value) && !is_array($value)) { $value = json_decode($value); } // if current language is present as key if (isset($value->{...
php
{ "resource": "" }
q27876
TranslatableTrait.appendLanguageKeys
train
public function appendLanguageKeys() { $attributes = $this->getAttributes(); foreach($attributes as $attrKey => $attr){ if(isset($this->translatableColumns[$attrKey])) { if(is_array($attr)) { continue; } if($attr == null...
php
{ "resource": "" }
q27877
EntityManager.getSerializer
train
public function getSerializer() { if(!$this->serializer) $this->serializer = new \Asgard\Entity\Serializer; return $this->serializer; }
php
{ "resource": "" }
q27878
EntityManager.makeDefinition
train
protected function makeDefinition($entityClass) { if($this->has($entityClass)) return $this->definitions[$entityClass]; $HookManager = $this->getHookManager(); $definition = false; if($cache = $this->getCache()) $definition = $cache->fetch('asgard.entityManager.'.$entityClass.'.definition'); if($defini...
php
{ "resource": "" }
q27879
Translator.get
train
public function get(string $key, string $locale = null) { $realKey = $this->getRealKey($key, $locale); return ArrayHelper::get($this->messages, $realKey); }
php
{ "resource": "" }
q27880
Scope.findLocale
train
public function findLocale($segment): ?Locale { return isset($this->locales[$segment]) ? Locale::from($this->locales[$segment]) : null; }
php
{ "resource": "" }
q27881
Scope.segment
train
public function segment($locale = null): ?string { if (is_null($locale)) { return $this->activeSegment(); } return ($key = array_search($locale, $this->locales)) ? $key : null; }
php
{ "resource": "" }
q27882
PageTranslationListener.preRemove
train
public function preRemove(PageTranslationInterface $translation) { /** @var \Ekyna\Bundle\CmsBundle\Model\PageInterface $translatable */ $translatable = $translation->getTranslatable(); if (null !== $parentPage = $translatable->getParent()) { $from = $translation->getPath(); ...
php
{ "resource": "" }
q27883
PageTranslationListener.updateChildrenPageTranslationPath
train
private function updateChildrenPageTranslationPath( PageInterface $page, UnitOfWork $uow, ClassMetadata $metadata, $from, $to, $locale ) { // TODO use url generator or i18n routing prefix strategy $localePrefix = $locale != 'fr' ? '/' . $locale : ''; ...
php
{ "resource": "" }
q27884
PageTranslationListener.postFlush
train
public function postFlush() { foreach ($this->redirections as $redirection) { $redirectionEvent = new BuildRedirectionEvent($redirection['from'], $redirection['to'], true); $this->dispatcher->dispatch(RedirectionEvents::BUILD, $redirectionEvent); } $this->redirection...
php
{ "resource": "" }
q27885
Client.inspect
train
public function inspect(?string $id, bool $size = false) { $url = self::$base_url.'/'.($id ?? $this->container_id).'/json?'.http_build_query(compact('size')); return self::$curl->get($url); }
php
{ "resource": "" }
q27886
Client.top
train
public function top(?string $id, string $ps_args = '-ef') { $url = self::$base_url.'/'.$id ?? $this->container_id.'/'.__FUNCTION__.'?'.http_build_query(['ps_args' => $ps_args]); return self::$curl->get($url); }
php
{ "resource": "" }
q27887
Client.logs
train
public function logs(string $id, bool $follow = false, bool $stdout = true, bool $stderr = false, int $since = 0, int $until = 0, bool $timestamps = false, ...
php
{ "resource": "" }
q27888
Client.stats
train
public function stats(?string $id, bool $stream = false) { $url = self::$base_url.'/'.($id ?? $this->container_id).'/stats?'.http_build_query(['stream' => $stream]); return self::$curl->get($url); }
php
{ "resource": "" }
q27889
Client.resize
train
public function resize(?string $id, int $height, int $width) { $url = self::$base_url.'/'.($id ?? $this->container_id).'/resize?'.http_build_query(compact( 'height', 'width' )); return self::$curl->post($url); }
php
{ "resource": "" }
q27890
Client.attachViaWebSocket
train
public function attachViaWebSocket(?string $id, string $detachKeys = null, bool $logs = false, bool $stream = false, bool $stdin = false, ...
php
{ "resource": "" }
q27891
Client.wait
train
public function wait(?string $id, string $condition = 'not - running') { $url = self::$base_url.'/'.($id ?? $this->container_id).'/wait?'.http_build_query(compact('condition')); return self::$curl->post($url); }
php
{ "resource": "" }
q27892
Client.getFileInfo
train
public function getFileInfo(?string $id, string $path) { $url = self::$base_url.'/'.($id ?? $this->container_id).'/archive?'.http_build_query([ 'path' => $path, ]); self::$curl->get($url); return self::$curl->getResponseHeaders(); }
php
{ "resource": "" }
q27893
Client.archive
train
public function archive(?string $id, string $path) { $url = self::$base_url.'/'.($id ?? $this->container_id).'/archive?'.http_build_query(['path' => $path]); return self::$curl->get($url); }
php
{ "resource": "" }
q27894
Client.extract
train
public function extract(?string $id, string $path, bool $noOverwriteDirNonDir, string $request) { $id = $id ?? $this->container_id; $url = self::$base_url.'/'.$id.'/archive?'.http_build_query(compact( 'path', 'noOverwriteDirNonDir' )); $output = ...
php
{ "resource": "" }
q27895
Preset.apply
train
function apply (Component $component) { if ($component->supportsProperties()) { if ($this->props) $component->props->applyDefaults ($this->props); if ($this->unset) foreach ($this->unset as $prop) unset ($component->props->$prop); } if ($this->content) { $compo...
php
{ "resource": "" }
q27896
Preset.ifMatchesApply
train
function ifMatchesApply (Component $component) { if ($this->matches ($component)) { $this->apply ($component); return true; } return false; }
php
{ "resource": "" }
q27897
Preset.matches
train
function matches (Component $component) { if ($this->matchTag && $this->matchTag !== $component->getTagName ()) return false; if ($this->matchClass && (!$component instanceof HtmlComponent || !preg_match ($this->matchClass, $component->props->class)) ) return false; if ($component-...
php
{ "resource": "" }
q27898
AddressParser.parse
train
public static function parse(string $address) { static $regex = null; if (null === $regex) { $grammar = Grammar::getInstance(); $addrSpec = $grammar->getDefinition('addr-spec'); $cfws = $grammar->getDefinition('CFWS'); $phrase = $grammar->getDefinitio...
php
{ "resource": "" }
q27899
DefaultSnippets.link
train
public function link($link, $text=null, $title=null, $popup=false, $class=null) { if (is_null($text)) { // if no text is given, we use the text originally provided by the user $text = $link; } // deal with internal and (slightly) malformed links $link = $this->getLink($link); $attributes = $this->getH...
php
{ "resource": "" }