_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q27700 | BlockController.removeAction | train | public function removeAction(Request $request)
{
$block = $this->findBlockByRequest($request);
$row = $block->getRow();
try {
$this->getEditor()->getBlockManager()->delete($block);
} catch (EditorExceptionInterface $e) {
return $this->handleException($e);
... | php | {
"resource": ""
} |
q27701 | BlockController.moveLeftAction | train | public function moveLeftAction(Request $request)
{
$block = $this->findBlockByRequest($request);
try {
$sibling = $this->getEditor()->getBlockManager()->moveLeft($block);
} catch (EditorExceptionInterface $e) {
return $this->handleException($e);
}
$r... | php | {
"resource": ""
} |
q27702 | MockedFunction.call | train | public function call(Arguments $values)
{
++$this->called;
if ($this->times > -1 && $this->called > $this->times) {
throw new ExpectationException("Function {$this->name}({$this->arguments}) should be called {$this->times} times but called at least {$this->called} times");
}
... | php | {
"resource": ""
} |
q27703 | GnMailsApi.GetMailsPage | train | public function GetMailsPage(int $lastKnownTicks = 0, int $pageSize = NULL)
{
$result = $this->ExecuteCall("GetMailsPage", (object)[
"lastKnownTicks" => $lastKnownTicks,
"pageSize" => $pageSize
], GnResponseType::ListGnMail);
return $result;
} | php | {
"resource": ""
} |
q27704 | GnMailsApi.SendMail | train | public function SendMail(string $toLoginName, string $mailBody)
{
$result = $this->ExecuteCall("SendMail", (object)[
"toLoginName" => $toLoginName,
"mailBody" => $mailBody
], GnResponseType::Json, FALSE, PHP_INT_MAX);
$this->ClearCacheForActionNames($this::CLEAR_CACH... | php | {
"resource": ""
} |
q27705 | Aggregate.canAggregateWithRepository | train | final public function canAggregateWithRepository(Repository $repository, Collection $collection)
{
$specificAggregate = $repository->getRepositorySpecificAggregate($this);
if ($specificAggregate) {
return $specificAggregate->canCalculateByRepository($repository, $collection);
}
... | php | {
"resource": ""
} |
q27706 | Aggregate.aggregateWithRepository | train | final public function aggregateWithRepository(Repository $repository, SqlStatement $sqlStatement, Collection $collection, &$namedParams)
{
$specificAggregate = $repository->getRepositorySpecificAggregate($this);
if ($specificAggregate) {
$specificAggregate->calculateByRepository($reposi... | php | {
"resource": ""
} |
q27707 | ByteNumberGenerator.getNumber | train | public function getNumber($min, $max)
{
$min = (int) $min;
$max = (int) $max;
if ($min > $max) {
throw new \InvalidArgumentException('Invalid minimum and maximum value');
}
if ($min === $max) {
return $min;
}
$difference = $max - $mi... | php | {
"resource": ""
} |
q27708 | ByteNumberGenerator.getByteNumber | train | private function getByteNumber($limit)
{
$bits = 1;
$mask = 1;
while ($limit >> $bits > 0) {
$mask |= 1 << $bits;
$bits++;
}
$bytes = (int) ceil($bits / 8);
do {
$result = $this->readByteNumber($bytes) & $mask;
} while ($... | php | {
"resource": ""
} |
q27709 | ByteNumberGenerator.readByteNumber | train | private function readByteNumber($bytes)
{
$values = unpack(self::$byteFormats[$bytes - 1], $this->byteGenerator->getBytes($bytes)) + self::$byteDefaults;
return $values['a'] | $values['b'] << 16 | $values['c'] << 32 | $values['d'] << 48;
} | php | {
"resource": ""
} |
q27710 | BlockManager.update | train | public function update(Model\BlockInterface $block, Request $request)
{
// Plugin update
return $this->editor
->getBlockPlugin($block->getType())
->update($block, $request);
} | php | {
"resource": ""
} |
q27711 | BlockManager.delete | train | public function delete(Model\BlockInterface $block)
{
// Ensure not named / alone
if ($block->isAlone() || $block->isNamed()) {
throw new InvalidOperationException(
"The block can't be removed because it is named or the parent row does not have enough children."
... | php | {
"resource": ""
} |
q27712 | BlockManager.moveDown | train | public function moveDown(Model\BlockInterface $block)
{
$row = $block->getRow();
if (null === $row || $row->isLast()) {
throw new InvalidOperationException(
"This block can't be moved to the top."
);
}
$sibling = $this->editor->getRepository()... | php | {
"resource": ""
} |
q27713 | BlockManager.moveLeft | train | public function moveLeft(Model\BlockInterface $block)
{
$sibling = $this->editor->getRepository()->findSiblingBlock($block, false);
if (null === $sibling) {
throw new InvalidOperationException(
"The block can't be moved to the right as no sibling block has been found."
... | php | {
"resource": ""
} |
q27714 | BlockManager.moveRight | train | public function moveRight(Model\BlockInterface $block)
{
$sibling = $this->editor->getRepository()->findSiblingBlock($block, true);
if (null === $sibling) {
throw new InvalidOperationException(
"The block can't be moved to the right as no sibling block has been found."
... | php | {
"resource": ""
} |
q27715 | PlaceHolderSet.append | train | public function append($placeHolder)
{
if ( ! $placeHolder instanceof PlaceHolder) {
throw new \LogicException(__METHOD__ . " accepts PlaceHolder arguments only");
}
if (isset($this->localization)) {
$placeHolderName = $placeHolder->getName();
// Add to final in cases when it's the page place... | php | {
"resource": ""
} |
q27716 | PlaceHolderSet.getLastByName | train | public function getLastByName($name)
{
$placeHolder = null;
/* @var $placeHolder PlaceHolder */
foreach ($this as $placeHolderTest) {
if ($placeHolderTest->getName() == $name) {
$placeHolder = $placeHolderTest;
}
}
return $placeHolder;
} | php | {
"resource": ""
} |
q27717 | eZGmapLocation.fetch | train | public static function fetch( $attributeId, $version, $asObject = true )
{
$list = eZPersistentObject::fetchObjectList(
self::definition(),
null,
array( 'contentobject_attribute_id' => $a... | php | {
"resource": ""
} |
q27718 | eZGmapLocation.removeById | train | static function removeById( $attributeId, $version = null )
{
if ( $version !== null )
$conds = array( 'contentobject_attribute_id' => $attributeId, 'contentobject_version' => $version );
else
$conds = array( 'contentobject_attribute_id' => $attributeId );
eZPersistentObject:... | php | {
"resource": ""
} |
q27719 | NestedSetListener.createNestedSetNode | train | private function createNestedSetNode(LifecycleEventArgs $args)
{
$entity = $args->getEntity();
if ($entity instanceof EntityNodeInterface) {
// Read entity data from the event arguments
$em = $args->getEntityManager();
// Find the repository
$entityName = $entity->getNestedSetRepositoryClassName()... | php | {
"resource": ""
} |
q27720 | ModuleInstaller.doUninstall | train | public function doUninstall(): void
{
$this->uninstallDB();
$this->uninstallFiles();
ModuleManager::unRegisterModule($this->MODULE_ID);
} | php | {
"resource": ""
} |
q27721 | ModuleInstaller.installFiles | train | public function installFiles(): void
{
if (!$this->isDevelopmentMode()) {
foreach ($this->INSTALL_PATHS as $path) {
$files = $this->getRecursiveFiles($path);
foreach ($files as $from => $to) {
$dir = dirname($to);
if (!file_exists($dir)) {
if (!mkdir($dir, BX_DIR_PERMISSIONS, true) && !is_... | php | {
"resource": ""
} |
q27722 | ModuleInstaller.uninstallFiles | train | public function uninstallFiles(): void
{
$isDirEmpty = function ($dir) {
if (!file_exists($dir) || !is_readable($dir)) {
return false;
}
return count(scandir($dir, SCANDIR_SORT_NONE)) === 2;
};
if (!$this->isDevelopmentMode()) {
foreach ($this->INSTALL_PATHS as $path) {
$files = $this->getRe... | php | {
"resource": ""
} |
q27723 | MainController.queryValues | train | protected function queryValues()
{
foreach($this->defaultQueryParameters as $parameter => $validator){
$value = request($parameter);
if($value) {
$this->{$parameter} = $value;
}
}
return $this;
} | php | {
"resource": ""
} |
q27724 | MainController.error | train | protected function error($errors = null, string $message = '')
{
if(!$errors) {
$errors = ['Your request has not been validated by the system. Please check your request URL and parameters!'];
}
// make it array
else if(!is_array($errors)) {
$errors = [$error... | php | {
"resource": ""
} |
q27725 | ComponentsAPITrait.createComponent | train | function createComponent ($class, Component $parent, $props = null, array $bindings = null)
{
/** @var Component $component */
$component = $this->injector->make ($class);
/** @var DocumentContext $this */
return $component->setup ($parent, $this, $props, $bindings);
} | php | {
"resource": ""
} |
q27726 | ComponentsAPITrait.createComponentFromTag | train | function createComponentFromTag ($tagName, Component $parent, array $props = null, array $bindings = null,
$generic = false, $strict = false)
{
$s = explode (':', $tagName, 2);
if (count ($s) > 1)
list ($prefix, $tagName) = $s;
else $prefix = '';
if (is_null ($... | php | {
"resource": ""
} |
q27727 | ContainerRepository.findOneById | train | public function findOneById($id)
{
$qb = $this->getQueryBuilder();
return $qb
->leftJoin('c.rows', 'row')
->leftJoin('row.blocks', 'block')
->leftJoin('block.translations', 'translation')
->addSelect('row', 'block', 'translation')
->andWhe... | php | {
"resource": ""
} |
q27728 | ContainerRepository.getCopyCount | train | public function getCopyCount(ContainerInterface $container)
{
$query = $this->getEntityManager()->createQuery(
"SELECT COUNT(c.id) FROM {$this->getClassName()} c WHERE c.copy = :copied"
);
/** @noinspection PhpIncompatibleReturnTypeInspection */
return $query
... | php | {
"resource": ""
} |
q27729 | UserModel.href | train | public function href($routeName = '', $customAttributes = [])
{
if(!$routeName) {
$routeName = 'user.single';
}
$getRoute = Route::getRoutes()->getByName($routeName);
if($getRoute) {
$routeParams = Route::getRoutes()->getByName($routeName)->parameterNames();
... | php | {
"resource": ""
} |
q27730 | CalendarController.listAction | train | public function listAction()
{
$calendars = $this->getDoctrine()
->getRepository('CanalTPMttBundle:Calendar')
->findBy(
['customer' => $this->getUser()->getCustomer()],
['id'=>'desc']
);
return $this->render('CanalTPMttBundle:Calen... | php | {
"resource": ""
} |
q27731 | CalendarController.exportAction | train | public function exportAction()
{
$applicationCanonicalName = $this->get('canal_tp_sam.application.finder')->getCurrentApp()->getCanonicalName();
$externalCoverageId = $this->getUser()->getCustomer()->getPerimeters()->first()->getExternalCoverageId();
$calendars = $this->getDoctrine()->getRep... | php | {
"resource": ""
} |
q27732 | LambdaController.doRun | train | protected function doRun($method, array $args=[]) {
ob_start();
$result = call_user_func_array($method, array_merge([$this], $args));
$controllerBuffer = ob_get_clean();
if($result !== null)
return $result;
if($controllerBuffer)
return $controllerBuffer;
return null;
} | php | {
"resource": ""
} |
q27733 | ReflectionClass.init | train | function init (ComponentPropertiesInterface $o)
{
foreach ($this->props as $p => $i)
$o->$p = $i->default;
return $o;
} | php | {
"resource": ""
} |
q27734 | ReflectionClass.setMetadataFromDefaultValue | train | private function setMetadataFromDefaultValue (ReflectionProperty $prop, $v)
{
$prop->default = $v;
// If the type has not yet been defined, it will be defined implicitly via the default value.
if (!isset($prop->type))
switch (gettype ($v)) {
case 'string':
$prop->type = type::stri... | php | {
"resource": ""
} |
q27735 | SmartyAssetsManager.prepareAssets | train | public function prepareAssets($assets_directory, \Smarty_Internal_Template $smarty)
{
// Be sure to use the proper path separator
if (DS != '/') {
$assets_directory = str_replace('/', DS, $assets_directory);
}
// Set the current template assets directory
self::$a... | php | {
"resource": ""
} |
q27736 | SmartyAssetsManager.prepareTemplateAssets | train | protected function prepareTemplateAssets(
TemplateDefinition $templateDefinition,
$assets_directory,
SmartyParser $smartyParser
) {
// Get the registered template directories for the current template type
$templateDirectories = $smartyParser->getTemplateDirectories($templateD... | php | {
"resource": ""
} |
q27737 | SmartyAssetsManager.computeAssetUrl | train | public function computeAssetUrl($assetType, $params, \Smarty_Internal_Template $template, $allowFilters = true)
{
$file = $params['file'];
// The 'file' parameter is mandatory
if (empty($file)) {
throw new \InvalidArgumentException(
"The 'file' parameter is missi... | php | {
"resource": ""
} |
q27738 | SeasonRepository.findSeasonByPerimeterAndDateTime | train | public function findSeasonByPerimeterAndDateTime(Perimeter $perimeter, \DateTime $dateTime)
{
$query = $this->getEntityManager()->createQueryBuilder()
->select("s.id")
->from("CanalTPMttBundle:Season", "s")
->where("s.published = TRUE")
... | php | {
"resource": ""
} |
q27739 | SeasonRepository.findByPerimeter | train | public function findByPerimeter(Perimeter $perimeter)
{
$qb = $this->createQueryBuilder('s');
$qb->where("s.perimeter = :perimeter")
->setParameter('perimeter', $perimeter)
->orderBy('s.startDate', 'DESC')
;
return $qb->getQuery()->getResult();
} | php | {
"resource": ""
} |
q27740 | PublicUrlEventSubscriber.onPagePublicUrl | train | public function onPagePublicUrl(ResourceEventInterface $event)
{
$resource = $event->getResource();
if (!$resource instanceof PageInterface) {
return;
}
$event->stopPropagation();
if (!$resource->isEnabled() || $resource->isDynamicPath()) {
return;
... | php | {
"resource": ""
} |
q27741 | BreadcrumbBuilder.createBreadcrumbRoot | train | private function createBreadcrumbRoot()
{
if (null === $this->breadcrumb) {
if (null === $home = $this->pageHelper->getHomePage()) {
throw new \RuntimeException('Home page not found.');
}
$this->breadcrumb = $this->factory->createItem('root', [
... | php | {
"resource": ""
} |
q27742 | Model.reload | train | public function reload()
{
$this->propertyCache = [];
$repository = $this->getRepository();
$repository->reHydrateObject($this, $this->uniqueIdentifier);
} | php | {
"resource": ""
} |
q27743 | Model.performAfterSave | train | protected function performAfterSave(callable $callback, $key = null)
{
if ($key) {
$this->callbacksToRunAfterSave[$key] = $callback;
} else {
$this->callbacksToRunAfterSave[] = $callback;
}
} | php | {
"resource": ""
} |
q27744 | Model.getRepository | train | final public function getRepository()
{
$repositories = &Application::current()->getSharedArray("ModelRepositories");
if (!isset($repositories[$this->modelName])) {
$repositories[$this->modelName] = $this->createRepository();
}
return $repositories[$this->modelName];
... | php | {
"resource": ""
} |
q27745 | Model.clearObjectCache | train | public static function clearObjectCache()
{
$object = SolutionSchema::getModel(get_called_class());
$repository = $object->getRepository();
$repository->clearObjectCache();
} | php | {
"resource": ""
} |
q27746 | Model.findFirst | train | public static function findFirst(Filter ...$filters)
{
$results = static::find(...$filters);
if (sizeof($results) == 0) {
throw new RecordNotFoundException(get_called_class(), 0);
}
return $results[0];
} | php | {
"resource": ""
} |
q27747 | Model.findLast | train | public static function findLast(Filter ...$filters)
{
$results = static::find(...$filters);
$modelClass = get_called_class();
/** @var Model $model */
$model = new $modelClass();
$results->addSort($model->getUniqueIdentifierColumnName(), false);
if (sizeof($results) ... | php | {
"resource": ""
} |
q27748 | Model.find | train | public static function find(Filter ...$filters)
{
$modelClass = get_called_class();
$collection = new RepositoryCollection($modelClass);
$collection->filter(...$filters);
return $collection;
} | php | {
"resource": ""
} |
q27749 | Model.save | train | final public function save($forceSaveRegardlessOfState = false)
{
try {
$this->isConsistent();
} catch (ModelConsistencyValidationException $er) {
// If the model isn't consistent we don't let it get into the database.
throw $er;
}
if (!$forceSave... | php | {
"resource": ""
} |
q27750 | Model.setUniqueIdentifier | train | public function setUniqueIdentifier($value)
{
$this->newRecord = $value === null;
$this->uniqueIdentifier = $value;
$this[$this->uniqueIdentifierColumnName] = $value;
} | php | {
"resource": ""
} |
q27751 | Model.getColumnSchemaForColumnReference | train | private function getColumnSchemaForColumnReference($columnReference, $fromModelSchema)
{
if (strpos($columnReference, ".") !== false) {
$parts = explode(".", $columnReference);
$relationshipName = $parts[0];
$this->ensureRelationshipsArePopulated();
$relatio... | php | {
"resource": ""
} |
q27752 | Model.isConsistent | train | final public function isConsistent($throwException = true)
{
$errors = $this->getConsistencyValidationErrors();
if (sizeof($errors) == 0) {
return true;
}
if ($throwException) {
throw new ModelConsistencyValidationException($errors);
}
retur... | php | {
"resource": ""
} |
q27753 | Model.loadFromUniqueIdentifier | train | protected function loadFromUniqueIdentifier($uniqueIdentifier)
{
$this->newRecord = false;
$repository = $this->getRepository();
$repository->hydrateObject($this, $uniqueIdentifier);
$this->onLoaded();
} | php | {
"resource": ""
} |
q27754 | CFileCache.get | train | public function get($key, $age = false)
{
$file = $this->filename($key);
if (is_file($file)) {
if ($age) {
$age = filemtime($file) + $this->config['age'] > time();
}
if (!$age) {
// json
// text
ret... | php | {
"resource": ""
} |
q27755 | CFileCache.put | train | public function put($key, $item)
{
$file = $this->filename($key);
// json
// text
if (!file_put_contents($file, serialize($item))) {
throw new \Exception(
t("Failed writing cache object '!key'.", [
'!key' => $key
])
... | php | {
"resource": ""
} |
q27756 | CFileCache.pruneAll | train | public function pruneAll()
{
$files = glob($this->config['basepath'] . '/*');
$items = count($files);
array_map('unlink', $files);
return $items;
} | php | {
"resource": ""
} |
q27757 | ViewModelTrait.getViewModel | train | function getViewModel ()
{
if (isset($this->shadowViewModel))
return $this->shadowViewModel;
/** @var DocumentFragment $shadowDOM */
$shadowDOM = $this->getShadowDOM ();
return $shadowDOM
? $shadowDOM->getDataBinder ()->getViewModel ()
: null;
} | php | {
"resource": ""
} |
q27758 | ViewModelTrait.afterPreRun | train | protected function afterPreRun ()
{
parent::afterPreRun ();
$vm = $this->getViewModel ();
if ($vm) {
$this->baseViewModel ($vm);
$this->viewModel ($vm);
$vm->init ();
}
} | php | {
"resource": ""
} |
q27759 | ViewModelTrait.baseViewModel | train | protected function baseViewModel (ViewModelInterface $viewModel)
{
$props = $this->props ? $this->props->getAll () : null;
if ($props)
$viewModel['props'] = $props;
} | php | {
"resource": ""
} |
q27760 | Supra.getConfigurationOverrides | train | public function getConfigurationOverrides()
{
if ($this->overrides) {
return $this->overrides;
}
return $this->overrides = $this->container['config.universal_loader']->load($this->getSupraRoot().'/config.yml'); //@todo: resolve config per environment
} | php | {
"resource": ""
} |
q27761 | Supra.addConfigurationSection | train | public function addConfigurationSection(SupraPackageInterface $package, $data)
{
$overrides = $this->getConfigurationOverrides();
if (isset($overrides[$package->getName()])) {
$processor = new Processor();
$data = $processor->processConfiguration($package->getConfiguration(), array(
$data,
$overrid... | php | {
"resource": ""
} |
q27762 | Supra.getConfigurationSection | train | public function getConfigurationSection($package)
{
if (!isset($this->configurationSections[$package])) {
throw new \Exception(sprintf('There is no configuration section for package "%s"', $package));
}
return $this->configurationSections[$package]['data'];
} | php | {
"resource": ""
} |
q27763 | Supra.resolveName | train | public function resolveName($package)
{
if (is_object($package)) {
$package = get_class($package);
}
$package = substr($package, strrpos($package, '\\'));
$package = trim($package, '\\');
$package = str_replace(array('Supra', 'Package'), '', $package);
return $package;
} | php | {
"resource": ""
} |
q27764 | Supra.buildDirectories | train | protected function buildDirectories()
{
$reflection = new \ReflectionClass($this);
$this->container->setParameter('directories.supra_root', dirname($reflection->getFileName()));
$this->container->setParameter('directories.project_root', dirname($this->container->getParameter('directories.supra_root')));
$this... | php | {
"resource": ""
} |
q27765 | Supra.finish | train | protected function finish(ContainerInterface $container)
{
foreach ($this->getPackages() as $package) {
$package->finish($container);
}
} | php | {
"resource": ""
} |
q27766 | Supra.injectPackages | train | protected function injectPackages(ContainerInterface $container)
{
foreach ($this->getPackages() as $package) {
$package->inject($container);
}
} | php | {
"resource": ""
} |
q27767 | Template.addLayout | train | public function addLayout($media, ThemeLayoutInterface $layout)
{
$templateLayout = new TemplateLayout($media);
$templateLayout->setLayoutName($layout->getName());
$templateLayout->setTemplate($this);
return $templateLayout;
} | php | {
"resource": ""
} |
q27768 | Template.hasLayout | train | public function hasLayout($media = TemplateLayout::MEDIA_SCREEN)
{
$has = $this->templateLayouts->offsetExists($media);
return $has;
} | php | {
"resource": ""
} |
q27769 | Template.getLayoutName | train | public function getLayoutName($media = TemplateLayout::MEDIA_SCREEN)
{
$templateLayouts = $this->getTemplateLayouts();
if ($templateLayouts->offsetExists($media)) {
$templateLayout = $templateLayouts->offsetGet($media);
/* @var $templateLayout TemplateLayout */
return $templateLayout->getLayoutName();
... | php | {
"resource": ""
} |
q27770 | AssetsHelpers.addJsRequirement | train | public function addJsRequirement($js, LambdaHelper $helper = null)
{
$js = trim($js);
$key = md5($js);
if (!isset(self::$jsRequirements[$key])) {
if ($helper !== null) {
$js = $helper->render($js);
}
self::$jsRequirements[$key] = $js;
... | php | {
"resource": ""
} |
q27771 | AssetsHelpers.addCssRequirement | train | public function addCssRequirement($css, LambdaHelper $helper = null)
{
$css = trim($css);
$key = md5($css);
if (!isset(self::$cssRequirements[$key])) {
if ($helper !== null) {
$css = $helper->render($css);
}
self::$cssRequirements[$key] =... | php | {
"resource": ""
} |
q27772 | BlockResponse.render | train | public function render(array $parameters = array())
{
if ($this->templateName === null) {
throw new \RuntimeException('Template name was not specified, nothing to render.');
}
$this->output(
$this->templating->render(
$this->templateName,
array_merge($this->parameters, $parameters)
)
);... | php | {
"resource": ""
} |
q27773 | Routes.mapBackendRoutes | train | public function mapBackendRoutes()
{
$directory = __DIR__.'/../../routes/backend';
if(is_dir($directory)) {
$routeFiles = File::files($directory);
\Route::group(
[
'middleware' => $this->middleware['backend'],
], function () use... | php | {
"resource": ""
} |
q27774 | Routes.mapFrontendRoutes | train | public function mapFrontendRoutes()
{
$directory = base_path('routes');
if(is_dir($directory)) {
$routeFiles = File::files($directory);
$excludeRoutes = ['base.php', 'api.php'];
Route::group(
[
'middleware' => $this->middleware['f... | php | {
"resource": ""
} |
q27775 | Routes.mapFrontendBaseRoutes | train | public function mapFrontendBaseRoutes()
{
$projectConfig = Config::get('project');
$baseFile = base_path('routes/base.php');
\Route::group(
[
'middleware' => $this->middleware['frontend'],
], function () use ($baseFile) {
include $baseFile... | php | {
"resource": ""
} |
q27776 | Routes.getRoutsFromTheme | train | public function getRoutsFromTheme($themeName)
{
if(Theme::ifExists($themeName)) {
$routeDir = base_path('themes/' . $themeName . '/routes');
if (is_dir($routeDir)) {
$routeFiles = File::files($routeDir);
// \Route::group([
... | php | {
"resource": ""
} |
q27777 | Routes.mapPluginsBackendRoutes | train | public function mapPluginsBackendRoutes()
{
foreach(Plugin::activePlugins() as $plugin){
$backendRoutes = $plugin->backendRoutes();
if($backendRoutes) {
\Route::group(
[
'middleware' => $this->middleware['backend'],
... | php | {
"resource": ""
} |
q27778 | Routes.mapPluginsFrontendRoutes | train | public function mapPluginsFrontendRoutes()
{
foreach(Plugin::activePlugins() as $plugin){
// Frontend routes
$frontendRoutes = $plugin->frontendRoutes();
if($frontendRoutes) {
\Route::group(
[
'middleware' => $this->... | php | {
"resource": ""
} |
q27779 | Routes.action | train | public function action($action, $parameters = [], $absolute = true)
{
$getProjectConfig = Config::get('project');
//add language if current language
if($getProjectConfig['multilanguage'] && App::getLocale() != Language::getDefault('slug')) {
$langParameter = array('lang'=> App::g... | php | {
"resource": ""
} |
q27780 | Routes.sortRoutes | train | public function sortRoutes()
{
$originalRoutes = \Route::getRoutes();
$routesByMethod = $originalRoutes->getRoutesByMethod();
//remove all previous routes
\Route::setRoutes(new RouteCollection());
$sortedRoutes = [];
foreach($routesByMethod as $method => $methodRout... | php | {
"resource": ""
} |
q27781 | ResultCollection.findByPhone | train | public function findByPhone(Phone $phone): Result
{
foreach ($this->results as $result) {
if ($result->getPhone()->getValue() === $phone->getValue()) {
return $result;
}
}
throw new ResultNotFoundException(sprintf(
'Not found result for ph... | php | {
"resource": ""
} |
q27782 | ResultCollection.getSuccessfullyResults | train | public function getSuccessfullyResults(): ResultCollection
{
$successfullyResults = array_filter($this->results, function (Result $result) {
return $result->isSuccessfully();
});
return new self(...$successfullyResults);
} | php | {
"resource": ""
} |
q27783 | ResultCollection.getFailedResults | train | public function getFailedResults(): ResultCollection
{
$failedResults = array_filter($this->results, function (Result $result) {
return $result->isFailed();
});
return new self(...$failedResults);
} | php | {
"resource": ""
} |
q27784 | File.url | train | public function url($default=null) {
if($this->isIn($this->webDir))
$src = $this->relativeToWebDir();
else
$src = $default;
if($this->url && $src)
return $this->url->to($src);
else
return $src;
} | php | {
"resource": ""
} |
q27785 | PdfPayloadsGenerator.getPayload | train | private function getPayload($perimeter, $season, $lineConfig, $externalRouteId, $stopPoint)
{
$payload = array();
$payload['pdfHash'] = isset($stopPoint->pdfHash) ? $stopPoint->pdfHash : '';
$payload['layoutParams'] = array(
'orientation' => $lineConfig->getLayoutConfig()->getLay... | php | {
"resource": ""
} |
q27786 | CAnaxDefault.loadRoutes | train | public function loadRoutes()
{
$routeFiles = $this->config["routeFiles"];
foreach ($routeFiles as $file) {
$this->loadFile($file, ["app" => $this]);
}
return $this;
} | php | {
"resource": ""
} |
q27787 | Mapper.collection | train | public function collection(TableQueryIterator $iterator, Table $definition) : Collection
{
return Collection::from($iterator)
->map(function ($v) use ($definition) {
return $this->entity($definition, $v);
});
} | php | {
"resource": ""
} |
q27788 | Mapper.save | train | public function save($entity)
{
$query = $this->db->table($entity->definition()->getName());
$primary = $entity->id();
if (!isset($this->objects[$entity->definition()->getName()][base64_encode(serialize($primary))])) {
$new = $query->insert($entity->toArray());
$entit... | php | {
"resource": ""
} |
q27789 | Mapper.delete | train | public function delete($entity)
{
$query = $this->db->table($entity->definition()->getName());
$primary = $entity->id();
if (isset($this->objects[$entity->definition()->getName()][base64_encode(serialize($primary))])) {
foreach ($primary as $k => $v) {
$query->fil... | php | {
"resource": ""
} |
q27790 | Base64Stream.fillBuffer | train | private function fillBuffer($length)
{
$fill = 8192;
while ($this->buffer->getSize() < $length) {
$read = $this->stream->read($fill);
if ($read === false || $read === '') {
break;
}
$this->buffer->write(base64_decode($read));
}
... | php | {
"resource": ""
} |
q27791 | Base64Stream.write | train | public function write($string)
{
$bytes = $this->remainder . $string;
$len = strlen($bytes);
if (($len % 3) !== 0) {
$this->remainder = substr($bytes, -($len % 3));
$bytes = substr($bytes, 0, $len - ($len % 3));
} else {
$this->remainder = '';
... | php | {
"resource": ""
} |
q27792 | Base64Stream.beforeClose | train | private function beforeClose()
{
if ($this->isWritable() && $this->remainder !== '') {
$this->stream->write(base64_encode($this->remainder));
$this->remainder = '';
}
} | php | {
"resource": ""
} |
q27793 | DynamicGroup.setData | train | public function setData(array $data) {
$this->data = $data;
$this->resetFields();
foreach($data as $name=>$data)
$this->newField($name, $data);
$this->updateChilds();
return $this;
} | php | {
"resource": ""
} |
q27794 | DynamicGroup.field | train | public function field($field=null) {
$default_render = $this->default_render;
if($default_render !== null)
return $default_render($field);
elseif($field instanceof Field)
return $field->def();
} | php | {
"resource": ""
} |
q27795 | DynamicGroup.renderTemplate | train | public function renderTemplate($offset='') {
$randstr = \Asgard\Common\Tools::randstr(10);
$jq = $this->renderNew('{{'.$randstr.'}}');
$jq = addcslashes((string)$jq, "'");
$jq = str_replace("\r\n", "\n", $jq);
$jq = str_replace("\n", "\\\n", $jq);
$jq = str_replace('{{'.$randstr.'}}', $offset, $jq);
... | php | {
"resource": ""
} |
q27796 | DynamicGroup.newField | train | protected function newField($name=null, $data=null) {
if($name !== null && isset($this[$name]))
return;
$cb = $this->cb;
$newelement = $cb($data);
if(!$newelement)
return;
$this->add($newelement, $name);
return $newelement;
} | php | {
"resource": ""
} |
q27797 | DynamicGroup.renderNew | train | protected function renderNew($offset=null) {
$default_render = $this->default_render;
if($offset === null)
$offset = $this->size();
if(!isset($this[$offset]))
$field = $this->newField($offset);
else
$field = $this[$offset];
if(!$field)
return;
if($default_render === null)
$r ... | php | {
"resource": ""
} |
q27798 | CRouterBasic.add | train | public function add($rule, $action = null)
{
$route = $this->di->get('route');
$route->set($rule, $action);
$this->routes[] = $route;
// Set as default route
if ($rule == "*") {
$this->defaultRoute = $route;
}
return $route;
} | php | {
"resource": ""
} |
q27799 | CRouterBasic.handle | train | public function handle()
{
try {
$query = $this->di->request->getRoute();
$parts = $this->di->request->getRouteParts();
// Match predefined routes
foreach ($this->routes as $route) {
if ($route->match($query)) {
return $rou... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.