_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q29500
OpauthRegisterForm.setRequiredFields
train
public function setRequiredFields($fields) { $this->requiredFields = $fields; $this->setValidator($this->getValidator()); return $this; }
php
{ "resource": "" }
q29501
OpauthRegisterForm.getFieldSource
train
public function getFieldSource() { if(is_callable(self::$field_source)) { $fields = call_user_func(self::$field_source, $this); if(!$fields instanceof FieldList) { throw new InvalidArgumentException('Field source must be callable and return a FieldList'); } return $fields; } return new FieldList(s...
php
{ "resource": "" }
q29502
OpauthRegisterForm.populateFromSources
train
public function populateFromSources(SS_HTTPRequest $request = null, Member $member = null, array $required = null) { $dataPath = "FormInfo.{$this->FormName()}.data"; if(isset($member)) { $this->loadDataFrom($member); } else if(isset($request)) { $this->loadDataFrom($request->postVars()); } // Hacky ag...
php
{ "resource": "" }
q29503
AccioCollection.paginate
train
public function paginate($perPage = 15, $page = null, $options = [], $setPath = null) { $page = $page ?: (Paginator::resolveCurrentPage() ?: 1); $items = ($this instanceof Collection || $this instanceof PostCollection) ? $this : Collection::make($this); $paginator = new LengthAwarePaginator(...
php
{ "resource": "" }
q29504
AccioCollection.orderBy
train
public function orderBy($key, $mode = 'ASC', $options = SORT_REGULAR) { return $this->sortBy($key, $options, ($mode === 'DESC' ? true : false)); }
php
{ "resource": "" }
q29505
AccioCollection.whereJson
train
public function whereJson($key, $operator, $value = null) { return $this->filter($this->jsonOperator(...func_get_args())); }
php
{ "resource": "" }
q29506
AccioCollection.jsonOperator
train
public function jsonOperator($key, $operator, $value = null) { if (func_num_args() === 2) { $value = $operator; $operator = '='; } return function ($item) use ($key, $operator, $value) { $column = $key; if(Str::contains($key, '->')) { ...
php
{ "resource": "" }
q29507
AccioCollection.setModel
train
public function setModel($eloquent, $table) { self::$_pathToClass = $eloquent; self::$_modelTable = $table; return $this; }
php
{ "resource": "" }
q29508
AccioCollection.getItems
train
public function getItems($pathToClass = null, $table = null) { if(!$pathToClass) { $pathToClass = self::$_pathToClass; } if(!$table) { $table = self::$_modelTable; } // TODO nese ne nje collection query e thirr nje collection tjeter, proprties ...
php
{ "resource": "" }
q29509
AccioCollection.refreshState
train
public function refreshState($cacheName, $item, $mode, $limitCache) { $cachedItems = $this->all(); // check if this item exists $currentItemKey = null; if($cachedItems) { $keyName = $item->getKeyName(); $keyValue = $item->getKey(); foreach ($cache...
php
{ "resource": "" }
q29510
THelpers.renderView
train
public function renderView($template, $data = []) { $template = $this->di->get("views")->getTemplateFile($template); $view = $this->di->get("view"); $view->setDI($this->di); $view->set($template, $data); $view->render(); }
php
{ "resource": "" }
q29511
THelpers.classList
train
public function classList(...$args) { $classes = []; foreach ($args as $arg) { if (empty($arg)) { continue; } elseif (is_string($arg)) { $arg = explode(" ", $arg); } $classes = array_merge($classes, $arg); } ...
php
{ "resource": "" }
q29512
THelpers.getContentForRoute
train
public function getContentForRoute($route) { $content = $this->di->get("content")->contentForInternalRoute($route); return $content->views["main"]["data"]; }
php
{ "resource": "" }
q29513
THelpers.wrapElementWithStartEnd
train
public function wrapElementWithStartEnd($text, $tag, $start, $end, $count) { return $this->di->get("textFilter")->wrapElementWithStartEnd($text, $tag, $start, $end, $count); }
php
{ "resource": "" }
q29514
THelpers.getPublishedDate
train
public function getPublishedDate($dates) { $defaults = [ "revision" => [], "published" => null, "updated" => null, "created" => null, ]; $dates = array_merge($defaults, $dates); if ($dates["revision"]) { return [t("...
php
{ "resource": "" }
q29515
CartController.getAddCartForm
train
private function getAddCartForm(Request $request) { /** @var CartAdd $cartAdd */ if ($request->isMethod("post")) { $cartAdd = $this->createForm(FrontForm::CART_ADD); } else { $cartAdd = $this->createForm( FrontForm::CART_ADD, "form", ...
php
{ "resource": "" }
q29516
BlockController.editAction
train
public function editAction( $externalNetworkId, $dom_id, $timetableId, $block_type = 'text', $stop_point = null ) { $blockTypeFactory = $this->get('canal_tp_mtt.form.factory.block'); $blockManager = $this->get('canal_tp_mtt.block_manager'); $timetableM...
php
{ "resource": "" }
q29517
ExceptionHandlerTrait.sendExceptionToSentry
train
protected function sendExceptionToSentry($exception) { if (!Bootstrap::$staticObjectManager instanceof ObjectManagerInterface) { return; } $options = $this->resolveCustomRenderingOptions($exception); if (isset($options['logException']) && $options['logException']) { ...
php
{ "resource": "" }
q29518
Month.fromString
train
public static function fromString($string) { return ctype_digit($string) ? new static((int) $string) : self::fromNative(new \DateTime($string)); }
php
{ "resource": "" }
q29519
Request.createFromGlobals
train
public static function createFromGlobals() { $request = new static; $request->get->setAll($_GET); $request->post->setAll($_POST); $request->setFiles($_FILES); $request->header->setAll(static::getAllHeaders()); $request->server->setAll($_SERVER); $request->cookie->setAll($_COOKIE); $request->body = file_...
php
{ "resource": "" }
q29520
Request.setFiles
train
public function setFiles($files) { $files = $this->parseFiles($files); $this->file->setAll($files); }
php
{ "resource": "" }
q29521
Request.parseFiles
train
protected function parseFiles(array $raw) { if(isset($raw['name']) && isset($raw['type']) && isset($raw['tmp_name']) && isset($raw['error']) && isset($raw['size'])) { if(is_array($raw['name'])) { $name = $this->convertTo('name', $raw['name']); $type = $this->convertTo('type', $raw['type']); $tmp_name =...
php
{ "resource": "" }
q29522
ArrayRepository.add
train
public function add(Node\NodeInterface $node) { $node->setRepository($this); parent::add($node); $this->array[] = $node; }
php
{ "resource": "" }
q29523
ArrayRepository.createNode
train
public function createNode($title = null) { $node = new Node\ArrayNode(); $node->setNodeTitle($title); $this->add($node); return $node; }
php
{ "resource": "" }
q29524
ArrayRepository.delete
train
public function delete(Node\NodeInterface $node) { $left = $node->getLeftValue(); $right = $node->getRightValue(); foreach ($this->array as $key => $item) { if ($item->getLeftValue() >= $left && $item->getRightValue() <= $right) { unset($this->array[$key]); } } }
php
{ "resource": "" }
q29525
ArrayRepository.search
train
public function search(SearchCondition\SearchConditionInterface $filter, SelectOrder\SelectOrderInterface $order = null) { if ( ! ($filter instanceof SearchCondition\ArraySearchCondition)) { throw new Exception\WrongInstance($filter, 'SearchCondition\ArraySearchCondition'); } $filterClosure = $filter->getSear...
php
{ "resource": "" }
q29526
ArrayRepository.searchByClosure
train
public function searchByClosure(\Closure $filterClosure, \Closure $orderClosure = null) { $result = array(); foreach ($this->array as $item) { if ($filterClosure($item)) { $result[] = $item; } } if ( ! \is_null($orderClosure)) { usort($result, $orderClosure); } return $result; }
php
{ "resource": "" }
q29527
CValidate.check
train
public function check($value, $rules, $throws = false) { $tests = [ 'fail' => [ 'message' => 'Will always fail.', 'test' => function () { return false; }, ], 'pass' => [ 'message' => 'Will...
php
{ "resource": "" }
q29528
FileStorage.find
train
public function find($fileId, $type = null) { if (! is_string($fileId)) { return null; } if (empty($type)) { $type = FileAbstraction::CN(); } return $this->getDoctrineEntityManager() ->find($type, $fileId); }
php
{ "resource": "" }
q29529
FileStorage.validateFileUpload
train
public function validateFileUpload(File $file, $sourceFilePath = null) { // file validation foreach ($this->fileUploadFilters as $filter) { /* @var $filter Validation\FileValidationInterface */ $filter->validateFile($file, $sourceFilePath); } }
php
{ "resource": "" }
q29530
FileStorage.storeFileData
train
public function storeFileData(File $file, $sourceFilePath) { $this->validateFileUpload($file, $sourceFilePath); $this->createBothFoldersInFileSystem($file); $filePath = $this->getFilesystemPath($file); if ( ! copy($sourceFilePath, $filePath)) { throw new Exception\RuntimeException('Failed to copy file fo...
php
{ "resource": "" }
q29531
FileStorage.renameFile
train
public function renameFile(File $file, $fileName) { $entityManager = $this->getDoctrineEntityManager(); $originFile = clone($file); $entityManager->detach($originFile); try { $file->setFileName($fileName); } catch (\Exception $e) { throw new Exception\UploadFilterException(self::VALIDATIO...
php
{ "resource": "" }
q29532
FileStorage.renameFolder
train
public function renameFolder(Folder $folder, $newTitle) { $entityManager = $this->getDoctrineEntityManager(); $entityManager->beginTransaction(); $oldFolder = clone($folder); $entityManager->detach($oldFolder); try { $folder->setFileName($newTitle); // validating folder before renaming foreach ($t...
php
{ "resource": "" }
q29533
FileStorage.createFolder
train
public function createFolder(Folder $folder) { // validating folder before creation foreach ($this->folderUploadFilters as $filter) { $filter->validateFolder($folder); } $this->createBothFoldersInFileSystem($folder); }
php
{ "resource": "" }
q29534
FileStorage.setPublic
train
public function setPublic(FileAbstraction $file, $public = true) { if ($file instanceof File) { $this->setPublicForFile($file, $public); } else if ($file instanceof Folder) { $this->setPublicForFolder($file, $public); } else { throw new Exception\RuntimeException('Wrong entity passed'); } }
php
{ "resource": "" }
q29535
FileStorage.moveFileToExternalStorage
train
private function moveFileToExternalStorage($filePath,Folder $folder = null) { $oldPath = $this->getInternalPath() . $filePath; $newPath = $this->getExternalPath() . $filePath; $this->createBothFoldersInFileSystem($folder); if ( ! rename($oldPath, $newPath)) { // throw new Exception\RuntimeException('Failed...
php
{ "resource": "" }
q29536
FileStorage.getImageSizeName
train
public function getImageSizeName($targetWidth, $targetHeight, $cropped = false) { $sizeName = $targetWidth . 'x' . $targetHeight; if ($cropped) { $sizeName .= 'cropped'; } return $sizeName; }
php
{ "resource": "" }
q29537
FileStorage.recreateImageSizes
train
protected function recreateImageSizes(Image $file) { if ( ! $file instanceof Image) { throw new Exception\RuntimeException('Image entity expected'); } $sizes = $file->getImageSizeCollection(); if ( ! $sizes->isEmpty()) { foreach ($sizes as $size) { $sizeName = $size->getName(); $filePath = $this...
php
{ "resource": "" }
q29538
FileStorage.rotateImageLeft
train
public function rotateImageLeft(Image $file, $quality = 95) { $this->rotateImage($file, ImageProcessor\ImageRotator::ROTATE_LEFT, $quality); }
php
{ "resource": "" }
q29539
FileStorage.rotateImageRight
train
public function rotateImageRight(Image $file, $quality = 95) { $this->rotateImage($file, ImageProcessor\ImageRotator::ROTATE_RIGHT, $quality); }
php
{ "resource": "" }
q29540
FileStorage.rotateImage180
train
public function rotateImage180(Image $file, $quality = 95) { $this->rotateImage($file, ImageProcessor\ImageRotator::ROTATE_180, $quality); }
php
{ "resource": "" }
q29541
FileStorage.getMimeType
train
public function getMimeType($filename) { if ( ! file_exists($filename)) { throw new Exception\RuntimeException('File does not exist'); } $finfo = finfo_open(FILEINFO_MIME_TYPE); $mimeType = finfo_file($finfo, $filename); finfo_close($finfo); return $mimeType; }
php
{ "resource": "" }
q29542
FileStorage.isSupportedImageFormat
train
public function isSupportedImageFormat($filename) { $info = new ImageInfo($filename); if ($info->hasError()) { $this->container->getLogger()->error($info->getError()); return false; } if ( ! $this->isMimeTypeImage($info->getMime())) { return false; } return ImageProcessor\ImageProcessor::isSuppo...
php
{ "resource": "" }
q29543
FileStorage.getImagePath
train
public function getImagePath(Image $file, $sizeName = null) { if ( ! $file instanceof Image) { throw new Exception\RuntimeException('Image entity expected'); } $path = $this->getFilesystemDir($file); $size = $file->findImageSize($sizeName); if ($size instanceof ImageSize) { $path .= self::RESERVE...
php
{ "resource": "" }
q29544
FileStorage.removeFileInFileSystem
train
private function removeFileInFileSystem(File $file) { $filePath = $this->getFilesystemPath($file); if (file_exists($filePath)) { $result = unlink($filePath); if ( ! $result) { throw new Exception\RuntimeException("Could not delete '$filePath' from file storage"); } } // remove sizes if object i...
php
{ "resource": "" }
q29545
FileStorage.remove
train
public function remove(FileAbstraction $entity) { $eventArgs = new FileEvent(); $eventArgs->setFile($entity); $this->fireFileEvent(FileEvent::FILE_EVENT_PRE_DELETE, $eventArgs); if ($entity instanceof Folder) { $hasChildren = $entity->hasChildren(); if ($hasChildren) { throw new Exception\NotEmptyEx...
php
{ "resource": "" }
q29546
FileStorage.removeFolder
train
private function removeFolder(Folder $folder) { $this->removeFolderInFileSystem($folder); $entityManager = $this->getDoctrineEntityManager(); $entityManager->remove($folder); $entityManager->flush(); }
php
{ "resource": "" }
q29547
FileStorage.removeFolderInFileSystem
train
private function removeFolderInFileSystem(Folder $folder) { $folderPath = $folder->getPath(DIRECTORY_SEPARATOR, true); $folderExternalPath = $this->getExternalPath() . $folderPath; $folderInternalPath = $this->getInternalPath() . $folderPath; //remove empty _size folders (or whatever the prefix is); we expec...
php
{ "resource": "" }
q29548
FileStorage.removeFile
train
private function removeFile(File $file) { $this->removeFileInFileSystem($file); if ($file instanceof Image) { $em = $this->getDoctrineEntityManager(); $imageSizeCn = ImageSize::CN(); $em->createQuery("DELETE FROM $imageSizeCn s WHERE s.master = :master") ->setParameter('master', $file->getId()) -...
php
{ "resource": "" }
q29549
FileStorage.fileExists
train
public function fileExists(FileAbstraction $file) { $path = $this->getFilesystemPath($file); $fileExists = file_exists($path); return $fileExists; }
php
{ "resource": "" }
q29550
ContentRepository.findOneByName
train
public function findOneByName($name) { $qb = $this->getQueryBuilder(); return $qb ->leftJoin('c.containers', 'container') ->leftJoin('container.rows', 'row') ->leftJoin('row.blocks', 'block') ->leftJoin('block.translations', 'block_t') ->a...
php
{ "resource": "" }
q29551
ContentRepository.findBySubject
train
public function findBySubject(ContentSubjectInterface $subject) { $content = $subject->getContent(); if (null !== $content && property_exists($content, '__isInitialized__') && !$content->{'__isInitialized__'}) { $qb = $this->getQueryBuilder(); $qb ->leftJoin(...
php
{ "resource": "" }
q29552
GnLoginApiAdmin.GenerateQrCode
train
public function GenerateQrCode(int $acls = GnMashupLoginAcl::None) { $qrCode = parent::GenerateQrCodeInternal(GnSettings::GPSNOSE_COMMUNITY, TRUE, TRUE, $acls); return $qrCode; }
php
{ "resource": "" }
q29553
JsonResponseContext.getArray
train
public function getArray(array $options = array()): array { $content = $this->getContent(); if (is_null($content)) { return (array)$content; } return json_decode($this->content, true); }
php
{ "resource": "" }
q29554
JsonResponseContext.getObject
train
public function getObject(array $options = array()) { $content = $this->getContent(); if (is_null($content)) { return (object)$content; } return json_decode($this->content, false); }
php
{ "resource": "" }
q29555
File.moveToDir
train
public function moveToDir($dir, $mode=null) { if($this->isIn($dir)) return; return $this->rename($dir.'/'.$this->getName(), $mode); }
php
{ "resource": "" }
q29556
File.isIn
train
public function isIn($dir) { if(!$this->formatPath($dir)) return false; return strpos($this->formatPath($this->src()), $this->formatPath($dir)) === 0; }
php
{ "resource": "" }
q29557
File.delete
train
public function delete() { if($r = \Asgard\File\FileSystem::delete($this->src)) { $this->src = null; $this->name = null; } return $r; }
php
{ "resource": "" }
q29558
Validator.checkIsNull
train
protected function checkIsNull($input) { $isNull = $this->isNull; if($isNull) return $isNull($input); else return $input === null || $input === ''; }
php
{ "resource": "" }
q29559
Validator.mergeErrors
train
protected function mergeErrors(array $errors1, array $errors2) { foreach($errors2['rules'] as $name=>$rule) { if(isset($errors1['rules'][$name])) { $i=1; while(isset($errors1['rules'][$name.'-'.$i])) { $i += 1; } $name = $name.'-'.$i; } $errors1['rules'][$name] = $rule; } foreach($errors2['at...
php
{ "resource": "" }
q29560
Validator.getMessage
train
protected function getMessage() { if($message = $this->defaultMessage) {} else $message = ':attribute is not valid.'; $params = [ 'attribute' => $this->getName(), ]; return $this->format($message, $params); }
php
{ "resource": "" }
q29561
Validator.buildRuleMessage
train
protected function buildRuleMessage($ruleName, $rule=null, $default=null, $input=null) { if($message = $this->getRuleMessage($ruleName)) {} elseif($message = $this->getRegistry()->getMessage($ruleName)) {} elseif($rule !== null && $message = $rule->getMessage()) {} elseif($default !== null && $message=$default)...
php
{ "resource": "" }
q29562
Validator.format
train
protected function format($message, array $params) { if($fm = $this->formatParameters) $fm($params); foreach($params as $k=>$v) { if(is_string($v) || is_numeric($v)) $message = str_replace(':'.$k, $v, $message); } return ucfirst($message); }
php
{ "resource": "" }
q29563
Fluent.delete
train
protected function delete(string $key): void { $this->resolver()->where('id', '=', $this->getKeyId($key))->delete(); }
php
{ "resource": "" }
q29564
BlockDetector.start
train
public function start() { if ($this->watcher !== null) { return; } $this->watcher = Loop::repeat($this->checkInterval, function () { // Use double defer to calculate complete tick time // instead of timer → defer time. Loop::unreference(Loop::defe...
php
{ "resource": "" }
q29565
BlockDetector.stop
train
public function stop() { if ($this->watcher === null) { return; } Loop::cancel($this->watcher); $this->watcher = null; }
php
{ "resource": "" }
q29566
OrderController.deliverView
train
public function deliverView() { $this->checkAuth(); $this->checkCartNotEmpty(); // check if the cart contains only virtual products $cart = $this->getSession()->getSessionCart($this->getDispatcher()); $deliveryAddress = $this->getCustomerAddress(); if ($cart->isVir...
php
{ "resource": "" }
q29567
OrderController.invoice
train
public function invoice() { $this->checkAuth(); $this->checkCartNotEmpty(); $this->checkValidDelivery(); $message = false; $orderPayment = $this->createForm(FrontForm::ORDER_PAYMENT); try { $form = $this->validateForm($orderPayment, "post"); ...
php
{ "resource": "" }
q29568
OrderController.checkStockNotEmpty
train
private function checkStockNotEmpty() { $cart = $this->getSession()->getSessionCart($this->getDispatcher()); $cartItems = $cart->getCartItems(); foreach ($cartItems as $cartItem) { $pse = $cartItem->getProductSaleElements(); $product = $cartItem->getProduct(); ...
php
{ "resource": "" }
q29569
OrderController.getCustomerAddress
train
protected function getCustomerAddress() { $deliveryAddress = null; $addressId = $this->getSession()->getOrder()->getChoosenDeliveryAddress(); if (null === $addressId) { $customer = $this->getSecurityContext()->getCustomerUser(); $deliveryAddress = AddressQuery::creat...
php
{ "resource": "" }
q29570
ReflectionModel.touchProperty
train
protected function touchProperty($propertyName) { if (in_array('$' . $propertyName, $this->touchedProperties)) { return false; } $this->touchedProperties[] = '$' . $propertyName; return true; }
php
{ "resource": "" }
q29571
ReflectionModel.writePhpDoc
train
public function writePhpDoc() { $fileContents = file_get_contents($this->getFileName()); $existingDoc = $this->getDocComment(); $serializer = new DocBlock\Serializer(); $newDoc = $serializer->getDocComment($this->classDocBlock); // PhpDocumentor inserts a space between @Sup...
php
{ "resource": "" }
q29572
CSession.name
train
public function name($aName = null) { $name = isset($aName) ? $aName : (isset($this->config['name']) ? $this->config['name'] : "anax"); session_name($name); }
php
{ "resource": "" }
q29573
CSession.get
train
public function get($key, $default = null) { return isset($_SESSION) && isset($_SESSION[$key]) ? $_SESSION[$key] : $default; }
php
{ "resource": "" }
q29574
CSession.readOnce
train
public function readOnce($key) { $read = $this->get($key); $this->delete($key); return $read; }
php
{ "resource": "" }
q29575
SupraBlowfishEncoder.isPasswordValid
train
public function isPasswordValid($encoded, $raw, $salt) { $expectedHash = crypt((string) $raw, $encoded); $valid = ($expectedHash === $encoded); return $valid; }
php
{ "resource": "" }
q29576
Inspect.installRuleset
train
protected function installRuleset() { if (!file_exists($this->pathRulesetLocal) || $this->confirm('Overwrite local configuration with our copy? (y/n) [y]') ) { $copy = copy($this->pathRulesetStock, $this->pathRulesetLocal); return $copy; } return...
php
{ "resource": "" }
q29577
Inspect.setPaths
train
protected function setPaths() { $pathPackage = realpath(__DIR__.'/../../../../'); $pathBase = realpath(base_path()); // Set CLI path. $this->pathCli = $pathBase.'/vendor/bin/'.$this::CLI_TOOL; if (!file_exists($this->pathCli)) { $this->pathCli = $pathPackage.'/ve...
php
{ "resource": "" }
q29578
CRouteBasic.match
train
public function match($query) { $ruleParts = explode('/', $this->rule); $queryParts = explode('/', $query); $ruleCount = count($ruleParts); //$querCount = count($queryParts); $match = false; for ($i = 0; $i < $ruleCount; $i++) { $rp = $ruleParts...
php
{ "resource": "" }
q29579
ImageSizes.add
train
protected function add(array $image_size_item) { array_walk($image_size_item, function (array $args, string $name) { add_image_size($name, $args[0], $args[1], isset($args[2]) ? $args[2] : false); }); }
php
{ "resource": "" }
q29580
NanoRest.sendRequest
train
public function sendRequest( RequestContext $requestContext ): ResponseContextAbstract { $curlHandle = $this->curlHelper->getRequestHandle($requestContext); $responseContext = $requestContext->getResponseContextObject(); list( 'httpStatus' => $status, 're...
php
{ "resource": "" }
q29581
BundleLoader.loadEntities
train
protected function loadEntities($entityManager) { foreach(glob($this->getPath().'/Entity/*.php') as $file) { $class = \Asgard\Common\Tools::loadClassFile($file); if(is_subclass_of($class, 'Asgard\Entity\Entity')) $entityManager->get($class); } }
php
{ "resource": "" }
q29582
BundleLoader.loadCommands
train
protected function loadCommands($console) { if(file_exists($this->getPath().'/Command/')) { foreach(glob($this->getPath().'/Command/*.php') as $filename) { $class = \Asgard\Common\Tools::loadClassFile($filename); if(is_subclass_of($class, 'Symfony\Component\Console\Command\Command')) { try { $co...
php
{ "resource": "" }
q29583
BundleLoader.loadHooks
train
protected function loadHooks() { $hooks = []; if(file_exists($this->getPath().'/Hook/')) { foreach(glob($this->getPath().'/Hook/*.php') as $filename) { $class = \Asgard\Common\Tools::loadClassFile($filename); if(is_subclass_of($class, 'Asgard\Hook\HookContainer')) $hooks = array_merge_recursive($hoo...
php
{ "resource": "" }
q29584
BundleLoader.loadControllers
train
protected function loadControllers() { $routes = []; if(file_exists($this->getPath().'/Controller/')) { foreach(glob($this->getPath().'/Controller/*.php') as $filename) { $class = \Asgard\Common\Tools::loadClassFile($filename); if(is_subclass_of($class, 'Asgard\Http\Controller')) $routes = array_mer...
php
{ "resource": "" }
q29585
oAuthAuthorizationCode.authorizationCodeUrl
train
public function authorizationCodeUrl() { // Get the Discovery URI if (!$this->endpointDiscovery()) return false; $url = $this->authorization_endpoint; $url .= '?response_type=code'; $url .= '&client_id=' . $this->mpClientId; $url .= '&scope=' . $this->scope . ' openi...
php
{ "resource": "" }
q29586
oAuthAuthorizationCode.acquireAccessToken
train
public function acquireAccessToken($code) { if (! $this->credentials) { $this->credentials = new Credentials('authorization_code'); // Get API endpoints $this->endpointDiscovery(); // Acquire the tokens and expiration and save $body = $this->acq...
php
{ "resource": "" }
q29587
oAuthAuthorizationCode.acquireUserInfo
train
public function acquireUserInfo() { // Request the userinfo $client = new Client(); //GuzzleHttp\Client $this->buildHttpHeader(); $endpoint = $this->userinfo_endpoint; try { $response = $client->request('GET', $endpoint, [ 'header' => $this->head...
php
{ "resource": "" }
q29588
oAuthAuthorizationCode.getAccessTokenFields
train
private function getAccessTokenFields($code) { $this->oAuthFields = [ 'grant_type' => 'authorization_code', 'code' => $code, 'redirect_uri' => $this->mpRedirectURL, 'client_id' => $this->mpClientId, 'client_secret' => $this->mpClientSecret, ...
php
{ "resource": "" }
q29589
oAuthAuthorizationCode.clear
train
public function clear() { if (!$this->credentials) { $this->credentials = new Credentials; } $this->credentials->forget(); return true; }
php
{ "resource": "" }
q29590
ContainerController.createRowAction
train
public function createRowAction(Request $request) { $container = $this->findContainer(intval($request->attributes->get('containerId'))); $target = is_null($container->getCopy()) ? $container : $container->getCopy(); try { $row = $this->getEditor()->createDefaultRow([], $target)...
php
{ "resource": "" }
q29591
ContainerController.editAction
train
public function editAction(Request $request) { $container = $this->findContainerByRequest($request); try { $response = $this->getEditor()->getContainerManager()->update($container, $request); } catch (EditorExceptionInterface $e) { return $this->handleException($e); ...
php
{ "resource": "" }
q29592
ContainerController.layoutAction
train
public function layoutAction(Request $request) { $container = $this->findContainerByRequest($request); $data = $request->request->get('data', []); try { $this->getEditor()->getLayoutAdapter()->updateContainerLayout($container, $data); } catch (EditorExceptionInterface $...
php
{ "resource": "" }
q29593
ContainerController.removeAction
train
public function removeAction(Request $request) { $container = $this->findContainerByRequest($request); $content = $container->getContent(); try { $this->getEditor()->getContainerManager()->delete($container); } catch (EditorExceptionInterface $e) { return $th...
php
{ "resource": "" }
q29594
ContainerController.moveDownAction
train
public function moveDownAction(Request $request) { $container = $this->findContainerByRequest($request); try { $sibling = $this->getEditor()->getContainerManager()->moveDown($container); } catch (EditorExceptionInterface $e) { return $this->handleException($e); ...
php
{ "resource": "" }
q29595
DataMapper.relationsErrors
train
public function relationsErrors(\Asgard\Entity\Entity $entity, $groups=[]) { $data = []; $validator = $this->createValidator($entity); $validator->set('entity', $entity); $validator->set('dataMapper', $this); foreach($this->relations($this->getEntityDefinition($entity)) as $name=>$relation) { $data[$...
php
{ "resource": "" }
q29596
DataMapper.entityORM
train
protected function entityORM(\Asgard\Entity\Entity $entity) { if($entity->isNew()) return $this->orm($entity->getClass()); else return $this->orm($entity->getClass())->where(['id' => $entity->id]); }
php
{ "resource": "" }
q29597
BaseTagController.getAllByPostType
train
public function getAllByPostType($lang = "", $postTypeID) { $orderBy = (isset($_GET['order'])) ? $orderBy = $_GET['order'] : 'tagID'; $orderType = (isset($_GET['type'])) ? $orderType = $_GET['type'] : 'DESC'; // get data return Tag::where('postTypeID', $postTypeID)->orderBy($orderBy,...
php
{ "resource": "" }
q29598
BaseTagController.delete
train
public function delete($lang, $id) { // check if user has permissions to access this link if(!User::hasAccess('Tags', 'delete')) { return $this->noPermission(); } $tagDeleteRes = $this->deleteTag($id); if(gettype($tagDeleteRes) == "boolean") { if($tag...
php
{ "resource": "" }
q29599
BaseTagController.bulkDelete
train
public function bulkDelete(Request $request) { // check if user has permissions to access this link if(!User::hasAccess('Tags', 'delete')) { return $this->noPermission(); } // if there are no item selected if (count($request->all()) <= 0) { return $th...
php
{ "resource": "" }