_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
language
stringclasses
1 value
meta_information
dict
q5300
View.resolveFullViewPath
train
private function resolveFullViewPath($viewPath) { if (strlen($this->getPartialsDir()) > 0 && strpos($viewPath, $this->getPartialsDir()) === 0) { return $this->resolvePartialPath($viewPath); }
php
{ "resource": "" }
q5301
View.resolveViewPath
train
private function resolveViewPath($viewPath) { $path = realpath($this->_viewsDir
php
{ "resource": "" }
q5302
View.resolvePartialPath
train
private function resolvePartialPath($viewPath) { $tempViewPath = str_replace($this->getPartialsDir(), '', $viewPath); if (strpos($tempViewPath, '../') === 0 || strpos($tempViewPath, '/../') === 0) { return $this->resolveRelativePath($tempViewPath); } else if (strpos($tempViewPath, './') === 0) { return $this->resolveLocalPath($tempViewPath);
php
{ "resource": "" }
q5303
View.resolveLocalPath
train
private function resolveLocalPath($partialPath) { $partialDir = str_replace('./', '', dirname($partialPath)); $partialsDir = realpath(sprintf('%s%s',
php
{ "resource": "" }
q5304
View.resolveRelativePath
train
private function resolveRelativePath($partialPath) { $partialsDirPath = realpath(sprintf('%s%s', $this->_viewsDir, dirname($partialPath)
php
{ "resource": "" }
q5305
View.render
train
public function render($controllerName, $actionName, $params = null) { if (empty($this->controllerViewPath)) { $this->setControllerViewPath($controllerName);
php
{ "resource": "" }
q5306
View.setControllerViewPath
train
public function setControllerViewPath($controllerName) { $this->controllerViewPath = str_replace('\\','/',strtolower($controllerName));
php
{ "resource": "" }
q5307
DfOAuthTwoProvider.getUserFromTokenResponse
train
public function getUserFromTokenResponse($response) { $user = $this->mapUserToObject($this->getUserByToken( $token = $this->parseAccessToken($response) )); $this->credentialsResponseBody = $response; if ($user instanceof User) { $user->setAccessTokenResponseBody($this->credentialsResponseBody);
php
{ "resource": "" }
q5308
Database.getDbConfig
train
private function getDbConfig() { if (file_exists(MODULES_DIR . DS . $this->currentRoute['module'] . '/Config/database.php')) { $dbConfig = require_once MODULES_DIR . DS . $this->currentRoute['module'] . '/Config/database.php'; if (!empty($dbConfig) && is_array($dbConfig)) { return $dbConfig; } else { throw new \Exception(ExceptionMessages::INCORRECT_CONFIG); } } else { if (file_exists(BASE_DIR . '/config/database.php')) { $dbConfig = require_once BASE_DIR . '/config/database.php';
php
{ "resource": "" }
q5309
Cache.getInstance
train
public static function getInstance($name) { if (!isset(static::$instances[$name])) {
php
{ "resource": "" }
q5310
Moderator.reloadBlacklist
train
public function reloadBlacklist() { $this->cache->flush($this->getCacheKey());
php
{ "resource": "" }
q5311
Moderator.check
train
public function check($model) { $moderated = false; foreach ($model->getModerateList() as $id => $moderation) { $rules = explode('|', $moderation); foreach ($rules as $rule) { $action = explode(':', $rule); $options = isset($action[1]) ? $action[1] : null; $method = $action[0]; if ($this->$method($model->$id, $options)) {
php
{ "resource": "" }
q5312
Moderator.getDriver
train
public function getDriver() { if ($this->driver) { return $this->driver; } // Get driver configuration $config = $this->getConfig('drivers.' . $this->getConfig('driver'), []); // Get driver class
php
{ "resource": "" }
q5313
Moderator.loadBlacklist
train
protected function loadBlacklist() { // Check if caching is enabled if ($this->getConfig('cache.enabled', false) === false) { return $this->blackListRegex = $this->createRegex();
php
{ "resource": "" }
q5314
Moderator.createRegex
train
protected function createRegex() { // Load list from driver if (empty($list = $this->getDriver()->getList())) { return null; } return sprintf('/\b(%s)\b/i', implode('|', array_map(function ($value) {
php
{ "resource": "" }
q5315
Inviqa_SymfonyContainer_Model_StoreConfigCompilerPass.process
train
public function process(ContainerBuilder $container) { $taggedServices = $container->findTaggedServiceIds( self::TAG_NAME ); foreach ($taggedServices as $id => $tag) {
php
{ "resource": "" }
q5316
DiskCache.path
train
public static function path($filename) { if ($filename[0] != "/") { $filename = static::$path . "/" . $filename; } if (substr($filename, -5) != ".json") { $filename .= ".json"; } $path = pathinfo($filename, PATHINFO_DIRNAME); # Ensure the cache directory exists if (!is_dir($path)) { if (!mkdir($path, 0777, true)) { throw new \Exception("Unable to create cache directory (" . $path . ")"); }
php
{ "resource": "" }
q5317
DiskCache.check
train
public static function check($filename) { if (!$filename = static::path($filename)) {
php
{ "resource": "" }
q5318
DiskCache.get
train
public static function get($filename, $mins = 0) { if (!$cache = static::check($filename)) { return null; } $limit = time() - ($mins * 60); if (!$mins || $cache > $limit) { $filename = static::path($filename);
php
{ "resource": "" }
q5319
DiskCache.set
train
public static function set($filename, $data) { $data = ["_disk_cache" => $data];
php
{ "resource": "" }
q5320
DiskCache.clear
train
public static function clear($filename) { $filename = static::path($filename); if (!file_exists($filename)) { return; } if (!unlink($filename)) {
php
{ "resource": "" }
q5321
DiskCache.call
train
public static function call($key, callable $func) { $trace = debug_backtrace(); if ($function = $trace[1]["function"]) { $key = $function . "_" . $key; if ($class = $trace[1]["class"]) { $key = str_replace("\\", "_", $class) . "_" . $key;
php
{ "resource": "" }
q5322
PackageImporter.cleanupPackages
train
public function cleanupPackages(Storage $storage, callable $callback = null) { $count = 0; $storageNode = $storage->node(); $query = new FlowQuery([$storageNode]); $query = $query->find('[instanceof Neos.MarketPlace:Package]'); $upstreamPackages = $this->getProcessedPackages(); foreach ($query as $package) { /** @var NodeInterface $package */ if (in_array($package->getProperty('title'), $upstreamPackages)) { continue;
php
{ "resource": "" }
q5323
PackageImporter.cleanupVendors
train
public function cleanupVendors(Storage $storage, callable $callback = null) { $count = 0; $storageNode = $storage->node(); $query = new FlowQuery([$storageNode]); $query = $query->find('[instanceof Neos.MarketPlace:Vendor]'); foreach ($query as $vendor) { /** @var NodeInterface $vendor */
php
{ "resource": "" }
q5324
Renderer.filterResponse
train
private function filterResponse(Response $response, Request $request, int $type): string { $event = new FilterResponseEvent($this->kernel, $request, $type, $response); $this->dispatcher->dispatch(KernelEvents::RESPONSE, $event); $this->dispatcher->dispatch(KernelEvents::FINISH_REQUEST, new FinishRequestEvent($this->kernel, $request, $type));
php
{ "resource": "" }
q5325
Renderer.varToString
train
private function varToString($var): string { if (\is_object($var)) { return \sprintf('an object of type %s', \get_class($var)); } if (\is_array($var)) { $a = []; foreach ($var as $k => $v) { $a[] = \sprintf('%s => ...', $k); } return \sprintf('an array ([%s])', \mb_substr(\implode(', ', $a), 0, 255)); } if (\is_resource($var)) {
php
{ "resource": "" }
q5326
Person.removeElectronicAddress
train
public function removeElectronicAddress(ElectronicAddress $electronicAddress) { $this->electronicAddresses->removeElement($electronicAddress); if
php
{ "resource": "" }
q5327
Person.setElectronicAddresses
train
public function setElectronicAddresses(Collection $electronicAddresses) { if ($this->primaryElectronicAddress !== null && !$this->electronicAddresses->contains($this->primaryElectronicAddress)) {
php
{ "resource": "" }
q5328
ExecuteQuery.fetch
train
public function fetch(Input $input) { return $this->bus->handle(
php
{ "resource": "" }
q5329
ExceptionListener.beforeException
train
public function beforeException() { /** * @param \Phalcon\Events\Event $event * @param \Phalcon\Dispatcher $dispatcher * @param \Exception $exception * @return callable */ return function(Event $event, Dispatcher $dispatcher, \Exception $exception) {
php
{ "resource": "" }
q5330
Analytics.render
train
public function render() { if (!$this->isEnabled()) { return; } if ($this->isAutomatic()) { $this->addItem("ga('send', '" . self::TYPE_PAGEVIEW . "');"); } if ($this->isAnonymised()) { $this->addItem("ga('set', 'anonymizeIp', true);"); } if ($this->application->environment() === 'dev') { $this->addItem("ga('create', '{$this->id}', {
php
{ "resource": "" }
q5331
Analytics.trackPage
train
public function trackPage($page = null, $title = null, $type = self::TYPE_PAGEVIEW) { if (!defined('self::TYPE_'. strtoupper($type))) { throw new AnalyticsArgumentException('Type variable can\'t be of this type.'); } $item = "ga('send', 'pageview');"; if ($page !== null || $title !== null) { $page = ($page === null ? "window.location.href" : "'{$page}'"); $title =
php
{ "resource": "" }
q5332
Analytics.trackEvent
train
public function trackEvent($category, $action, $label = null, $value = null) { $item = "ga('send', 'event', '{$category}', '{$action}'" . ($label !== null ? ", '{$label}'" : '') . ($value
php
{ "resource": "" }
q5333
Analytics.trackTransaction
train
public function trackTransaction($id, array $options = []) {
php
{ "resource": "" }
q5334
Analytics.trackItem
train
public function trackItem($id, $name, array $options = []) { $options['id'] = $id; $options['name'] = $name;
php
{ "resource": "" }
q5335
Analytics.trackMetric
train
public function trackMetric($category, array $options = []) { $item = "ga('send', 'event', '{$category}'"; if (!empty($options)) { $item .= ", 'action', { "; foreach ($options as $key =>
php
{ "resource": "" }
q5336
Analytics.trackException
train
public function trackException($description = null, $fatal = false) { $item = "ga('send', '" . self::TYPE_EXCEPTION . "'"; if ($description !== null && is_bool($fatal)) { $item .= ", { " .
php
{ "resource": "" }
q5337
RegisterFiltersTrait.registerFilters
train
public function registerFilters () { foreach (glob($this->getFiltersDirectoryPath() . '*.php') as $file) { $filterName = pathinfo($file,
php
{ "resource": "" }
q5338
BaseOAuthService.handleLogin
train
public function handleLogin($request) { /** @var RedirectResponse $response */ $response = $this->provider->redirect(); $traitsUsed = class_uses($this->provider); $traitTwo = DfOAuthTwoProvider::class; $traitOne = DfOAuthOneProvider::class; if (isset($traitsUsed[$traitTwo])) { $state = $this->provider->getState(); if (!empty($state)) { $key = static::CACHE_KEY_PREFIX . $state; \Cache::put($key, $this->getName(), 3); } } elseif (isset($traitsUsed[$traitOne])) {
php
{ "resource": "" }
q5339
BaseOAuthService.handleOAuthCallback
train
public function handleOAuthCallback() { $provider = $this->getProvider(); /** @var OAuthUserContract $user */
php
{ "resource": "" }
q5340
BaseOAuthService.loginOAuthUser
train
public function loginOAuthUser(OAuthUserContract $user) { /** @noinspection PhpUndefinedFieldInspection */ $responseBody = $user->accessTokenResponseBody; /** @noinspection PhpUndefinedFieldInspection */ $token = $user->token; $dfUser = $this->createShadowOAuthUser($user); $dfUser->last_login_date = Carbon::now()->toDateTimeString(); $dfUser->confirm_code = null; $dfUser->save(); $map = OAuthTokenMap::whereServiceId($this->id)->whereUserId($dfUser->id)->first(); if (empty($map)) { OAuthTokenMap::create( [ 'user_id' => $dfUser->id, 'service_id' => $this->id, 'token' => $token, 'response' => $responseBody
php
{ "resource": "" }
q5341
BaseOAuthService.createShadowOAuthUser
train
public function createShadowOAuthUser(OAuthUserContract $OAuthUser) { $fullName = $OAuthUser->getName(); @list($firstName, $lastName) = explode(' ', $fullName); $email = $OAuthUser->getEmail(); $serviceName = $this->getName(); $providerName = $this->getProviderName(); if (empty($email)) { $email = $OAuthUser->getId() . '+' . $serviceName . '@' . $serviceName . '.com'; } else { list($emailId, $domain) = explode('@', $email); $email = $emailId . '+' . $serviceName . '@' . $domain; } $user = User::whereEmail($email)->first(); if (empty($user)) { $data = [ 'username' => $email, 'name' => $fullName, 'first_name' => $firstName, 'last_name'
php
{ "resource": "" }
q5342
ReadNestedAttributeTrait.traverseObject
train
private function traverseObject($obj, $keys) { if (empty($keys)) { return $obj; } $key = current($keys); if (is_array($obj) && isset($obj[$key])) { return $this->traverseObject($obj[$key], array_slice($keys, 1));
php
{ "resource": "" }
q5343
TaskListener.beforeHandleTask
train
public function beforeHandleTask($argv) { return function(Event $event, Console $console, Dispatcher $dispatcher) use ($argv) { //parse parameters $parsedOptions = OptionParser::parse($argv); $dispatcher->setParams(array( 'activeTask' => isset($parsedOptions[0]) ? $parsedOptions[0] : false,
php
{ "resource": "" }
q5344
Router.findPattern
train
private function findPattern($matches) { switch ($matches[1]) { case ':num': $replacement = '([0-9]'; break; case ':alpha': $replacement = '([a-zA-Z]'; break; case ':any': $replacement = '([^\/]'; break; } if (isset($matches[3]) && is_numeric($matches[3])) { if (isset($matches[4]) && $matches[4] == '?') { $replacement .= '{0,' . $matches[3] . '})';
php
{ "resource": "" }
q5345
MappingHelperTrait.toMappedArray
train
public function toMappedArray() { $values = $this->toArray(); $mappedValues = []; foreach ($values as $key => $value) {
php
{ "resource": "" }
q5346
MappingHelperTrait.readMapped
train
public function readMapped($name) { if (!$this->hasMapping($name) && isset($this->mappings[$name])) { $this->addMapping($name, $this->mappings[$name]); }
php
{ "resource": "" }
q5347
Dict.value
train
public static function value(array $data, $key, $default = null) { $value = static::valueIfSet($data, $key, $default); if ($value) {
php
{ "resource": "" }
q5348
SqlUserRepository.exist
train
private function exist(User $aUser) { $count = $this->execute( 'SELECT COUNT(*) FROM user WHERE id = :id', [':id' =>
php
{ "resource": "" }
q5349
SqlUserRepository.insert
train
private function insert(User $aUser) { $sql = 'INSERT INTO user ( id, confirmation_token_token, confirmation_token_created_on, created_on, email, invitation_token_token, invitation_token_created_on, last_login, password, salt, remember_password_token_token, remember_password_token_created_on, roles, updated_on ) VALUES ( :id, :confirmationTokenToken, :confirmationTokenCreatedOn, :createdOn, :email, :invitationTokenToken, :invitationTokenCreatedOn, :lastLogin, :password, :salt, :rememberPasswordTokenToken, :rememberPasswordTokenCreatedOn, :roles, :updatedOn )'; $this->execute($sql, [ 'id' => $aUser->id()->id(), 'confirmationTokenToken' => $aUser->confirmationToken() ? $aUser->confirmationToken()->token() : null, 'confirmationTokenCreatedOn' => $aUser->confirmationToken() ? $aUser->confirmationToken()->createdOn() : null, 'createdOn' => $aUser->createdOn()->format(self::DATE_FORMAT), 'email'
php
{ "resource": "" }
q5350
SqlUserRepository.execute
train
private function execute($aSql, array $parameters) { $statement = $this->pdo->prepare($aSql);
php
{ "resource": "" }
q5351
SqlUserRepository.buildUser
train
private function buildUser($row) { $createdOn = new \DateTimeImmutable($row['created_on']); $updatedOn = new \DateTimeImmutable($row['updated_on']); $lastLogin = null === $row['last_login'] ? null : new \DateTimeImmutable($row['last_login']); $confirmationToken = null; if (null !== $row['confirmation_token_token']) { $confirmationToken = new UserToken($row['confirmation_token_token']); $this->set($confirmationToken, 'createdOn', new \DateTimeImmutable($row['confirmation_token_created_on'])); } $invitationToken = null; if (null !== $row['invitation_token_token']) { $invitationToken = new UserToken($row['invitation_token_token']);
php
{ "resource": "" }
q5352
Searcher.setFields
train
public function setFields(array $models) { try { // need to return << true $this->validator->verify($models, [ 'isArray', 'isNotEmpty', 'isExists' ], 'where');
php
{ "resource": "" }
q5353
Searcher.setThreshold
train
public function setThreshold($threshold) { // need to return << true if (is_array($threshold) === true) { $threshold = array_map('intval', array_splice($threshold, 0, 2)); } else {
php
{ "resource": "" }
q5354
Searcher.setQuery
train
public function setQuery($query = null) { try { // need to return << true $this->validator->verify($query, ['isNotNull', 'isAcceptLength']); if (false === $this->exact) {
php
{ "resource": "" }
q5355
Searcher.run
train
final public function run($hydratorset = null, $callback = null) { try { // call to get result $result = (new Builder($this))->loop($hydratorset, $callback);
php
{ "resource": "" }
q5356
ApiController.soapServerAction
train
public function soapServerAction() { try { $apiModel = $this->_getModelName($this->obj); //parametry WSDL $wsdlParams = [ 'module' => 'cms', 'controller' => 'api', 'action' => 'wsdl', 'obj' => $this->obj, ]; //prywatny serwer if (\Mmi\App\FrontController::getInstance()->getEnvironment()->authUser) { $apiModel .= 'Private'; $auth = new \Mmi\Security\Auth;
php
{ "resource": "" }
q5357
File._checkAndCopyFile
train
protected static function _checkAndCopyFile(\Mmi\Http\RequestFile $file, $allowedTypes = []) { //pomijanie plików typu bmp (bitmapy windows - nieobsługiwane w PHP) if ($file->type == 'image/x-ms-bmp' || $file->type == 'image/tiff') { $file->type = 'application/octet-stream'; } //plik nie jest dozwolony if (!empty($allowedTypes) && !in_array($file->type, $allowedTypes)) { return null; } //pozycja ostatniej kropki w nazwie - rozszerzenie pliku $pointPosition = strrpos($file->name, '.'); //kalkulacja nazwy systemowej $name = md5(microtime(true) . $file->tmpName) . (($pointPosition !== false) ? substr($file->name, $pointPosition) : ''); //określanie ścieżki
php
{ "resource": "" }
q5358
File.move
train
public static function move($srcObject, $srcId, $destObject, $destId) { $i = 0; //przenoszenie plików foreach (CmsFileQuery::byObject($srcObject, $srcId)->find() as $file) { //nowy obiekt i id $file->object = $destObject;
php
{ "resource": "" }
q5359
File.copy
train
public static function copy($srcObject, $srcId, $destObject, $destId) { $i = 0; //kopiowanie plików foreach (CmsFileQuery::byObject($srcObject, $srcId)->find() as $file) { try { //tworzenie kopii $copy = new \Mmi\Http\RequestFile([ 'name' => $file->original, 'tmp_name' => $file->getRealPath(), 'size' => $file->size ]); } catch (\Mmi\App\KernelException $e) {
php
{ "resource": "" }
q5360
File._updateRecordFromRequestFile
train
protected static function _updateRecordFromRequestFile(\Mmi\Http\RequestFile $file, \Cms\Orm\CmsFileRecord $record) { //typ zasobu $record->mimeType = $file->type; //klasa zasobu $class = explode('/', $file->type); $record->class = $class[0]; //oryginalna nazwa pliku $record->original = $file->name; //rozmiar pliku $record->size = $file->size; //daty dodania i modyfikacji if (!$record->dateAdd) { $record->dateAdd = date('Y-m-d H:i:s'); } if (!$record->dateModify)
php
{ "resource": "" }
q5361
RegistrationController.setContainer
train
public function setContainer(ContainerInterface $container = NULL) { parent::setContainer($container);
php
{ "resource": "" }
q5362
TaskGettextScanner.extract
train
public function extract($path, $regex = null) { $directory = new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS); $iterator = new RecursiveIteratorIterator($directory); if ($regex) {
php
{ "resource": "" }
q5363
TaskGettextScanner.scan
train
private function scan(Translations $translations) { foreach ($this->iterator as $each) { foreach ($each as $file) { if ($file === null || !$file->isFile()) { continue; } $target = $file->getPathname();
php
{ "resource": "" }
q5364
TaskGettextScanner.getFunctionName
train
private function getFunctionName($prefix, $file, $suffix, $key = 0) { if (preg_match(self::getRegex(), strtolower($file), $matches)) { $format = self::$suffixes[$matches[1]]; if (is_array($format)) {
php
{ "resource": "" }
q5365
TaskGettextScanner.getRegex
train
private static function getRegex() { if (self::$regex === null) { self::$regex = '/('.str_replace('.', '\\.', implode('|',
php
{ "resource": "" }
q5366
UserHelper.setPassword
train
public function setPassword(User $user, $password) { $encoder = $this->container->get('security.encoder_factory') ->getEncoder($user); $salt = $this->createSalt();
php
{ "resource": "" }
q5367
UserHelper.createSalt
train
private function createSalt($max = 15) { $characterList = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; $i = 0; $salt = ""; do {
php
{ "resource": "" }
q5368
UserHelper.giveOwnRights
train
public function giveOwnRights($user) { $aclProvider = $this->container->get('security.acl.provider'); $maskBuilder = new MaskBuilder(); $usid = UserSecurityIdentity::fromAccount($user); $uoid = ObjectIdentity::fromDomainObject($user); foreach($this->container->getParameter("fom_user.user_own_permissions") as $permission) { $maskBuilder->add($permission); } $umask = $maskBuilder->get();
php
{ "resource": "" }
q5369
MongodbController.modelCommand
train
public function modelCommand($input, $modelName, $optimized = false) { if (strpos($modelName, '\\') === false) { $modelName = 'App\\Models\\' . ucfirst($modelName); } $fieldTypes = $this->_inferFieldTypes([$input]); $model = $this->_renderModel($fieldTypes, $modelName, 'mongodb', $optimized);
php
{ "resource": "" }
q5370
MongodbController.modelsCommand
train
public function modelsCommand($services = [], $namespace = 'App\Models', $optimized = false, $sample = 1000, $db = []) { if (strpos($namespace, '\\') === false) { $namespace = 'App\\' . ucfirst($namespace) . '\\Models'; } foreach ($this->_getServices($services) as $service) { /** * @var \ManaPHP\Mongodb $mongodb */ $mongodb = $this->_di->getShared($service); $defaultDb = $mongodb->getDefaultDb(); foreach ($defaultDb ? [$defaultDb] : $mongodb->listDatabases() as $cdb) { if (in_array($cdb, ['admin', 'local'], true) || ($db && !in_array($cdb, $db, true))) { continue; } foreach ($mongodb->listCollections($cdb) as $collection) { if (strpos($collection, '.')) { continue; } if (!$docs = $mongodb->aggregate("$cdb.$collection", [['$sample' => ['size' => $sample]]])) {
php
{ "resource": "" }
q5371
MongodbController.csvCommand
train
public function csvCommand($services = [], $collection_pattern = '', $bom = false) { foreach ($this->_getServices($services) as $service) { /** * @var \ManaPHP\Mongodb $mongodb */ $mongodb = $this->_di->getShared($service); $defaultDb = $mongodb->getDefaultDb(); foreach ($defaultDb ? [$defaultDb] : $mongodb->listDatabases() as $db) { if (in_array($db, ['admin', 'local'], true)) { continue; } foreach ($mongodb->listCollections($db) as $collection) { if ($collection_pattern && !fnmatch($collection_pattern, $collection)) { continue; } $fileName = "@tmp/mongodb_csv/$db/$collection.csv"; $this->console->progress(['`:collection` processing...', 'collection' => $collection], ''); $this->filesystem->dirCreate(dirname($fileName)); $file = fopen($this->alias->resolve($fileName), 'wb'); if ($bom) {
php
{ "resource": "" }
q5372
MongodbController.listCommand
train
public function listCommand($services = [], $collection_pattern = '', $field = '', $db = []) { foreach ($this->_getServices($services) as $service) { /** * @var \ManaPHP\Mongodb $mongodb */ $mongodb = $this->_di->getShared($service); $defaultDb = $mongodb->getDefaultDb(); foreach ($defaultDb ? [$defaultDb] : $mongodb->listDatabases() as $cdb) { if ($db && !in_array($cdb, $db, true)) { continue; } $this->console->writeLn(['---`:db` db of `:service` service---', 'db' => $cdb, 'service' => $service], Console::BC_CYAN);
php
{ "resource": "" }
q5373
Filter.addDefinition
train
public function addDefinition($type, $value, $field) { $definition = new \stdClass(); $definition->type = $type; $definition->value =
php
{ "resource": "" }
q5374
Model.rise
train
public function rise(array $params, $line, $filename) { $this->invoke = [ 'MODEL_DOES_NOT_EXISTS' => function ($params, $filename, $line) { // set message for not existing column $this->message = "Model `" . $params[1] . "` not exists. File: "
php
{ "resource": "" }
q5375
RoleAjax.postDeleteRole
train
public function postDeleteRole() { $response = (object)array( 'method' => 'deleterole', 'success' => false, 'status' => 200, 'error_code' => 0, 'error_message' => '' ); // decode json data $data = json_decode(file_get_contents("php://input")); if( empty($data)) { $data = (object) $_POST; } $requiredParams = array('id'); try { AuthorizerHelper::can(RoleValidator::ROLE_CAN_DELETE); $data = (array) $data; foreach ($requiredParams as $param){ if (empty($data[$param])) { throw new \Exception(ucfirst($param) .' is required.'); } } $roleModel = new \erdiko\users\models\Role(); $roleId = $roleModel->delete($data['id']);
php
{ "resource": "" }
q5376
Flash.output
train
public function output($remove = true) { $context = $this->_context; foreach ($context->messages as $message) { echo $message;
php
{ "resource": "" }
q5377
TextController.editAction
train
public function editAction() { $form = new \CmsAdmin\Form\Text(new \Cms\Orm\CmsTextRecord($this->id)); $this->view->textForm = $form; //brak wysłanych danych if (!$form->isMine()) { return; } //zapisany
php
{ "resource": "" }
q5378
Youtube.getThumbnailUrl
train
public function getThumbnailUrl(Tube $video) { if (0 === strlen($this->thumbnailSize)) {
php
{ "resource": "" }
q5379
ClassMetadata.getPropertyValue
train
public function getPropertyValue($user, $property = self::LOGIN_PROPERTY, $strict = false) { if ($this->checkProperty($property, $strict)) { $oid = spl_object_hash($user); if (null !== $cacheHit = $this->resolveCache($oid, $property)) {
php
{ "resource": "" }
q5380
ClassMetadata.getPropertyName
train
public function getPropertyName($property = self::LOGIN_PROPERTY, $strict = false) { if ($this->checkProperty($property, $strict)) { if (is_string($this->properties[$property])) { return $this->properties[$property]; } if (isset($this->lazyPropertyNameCache[$property])) {
php
{ "resource": "" }
q5381
ClassMetadata.modifyProperty
train
public function modifyProperty($user, $newValue, $property = self::LOGIN_PROPERTY) { $this->checkProperty($property, true); $propertyObject = $this->properties[$property]; if (is_string($propertyObject)) { $this->properties[$property] = $propertyObject = new ReflectionProperty($user, $propertyObject); } $propertyObject->setAccessible(true); $propertyObject->setValue($user, $newValue);
php
{ "resource": "" }
q5382
ClassMetadata.checkProperty
train
private function checkProperty($property = self::LOGIN_PROPERTY, $strict = false) { if (!isset($this->properties[$property])) { if ($strict) { throw new \LogicException(sprintf(
php
{ "resource": "" }
q5383
ClassMetadata.resolveCache
train
private function resolveCache($oid, $property) { if (isset($this->lazyValueCache[$oid])) { if (isset($this->lazyValueCache[$oid][$property])) { return
php
{ "resource": "" }
q5384
RepositoryGeneratorServiceProvider.registerMakeCommand
train
protected function registerMakeCommand() { $this->app->singleton('command.repository.make', function ($app) { $prefix = $app['config']['repository.prefix']; $suffix = $app['config']['repository.suffix']; $contract = $app['config']['repository.contract']; $namespace = $app['config']['repository.namespace']; $creator = $app['repository.creator'];
php
{ "resource": "" }
q5385
Response.setCookie
train
public function setCookie($name, $value, $expire = 0, $path = null, $domain = null, $secure = false, $httpOnly = true) { $context = $this->_context; if ($expire > 0) { $current = time(); if ($expire < $current) { $expire += $current; } } $context->cookies[$name] = [ 'name' => $name, 'value' => $value,
php
{ "resource": "" }
q5386
Response.setStatus
train
public function setStatus($code, $text = null) { $context = $this->_context;
php
{ "resource": "" }
q5387
Response.setHeader
train
public function setHeader($name, $value) { $context = $this->_context;
php
{ "resource": "" }
q5388
Response.redirect
train
public function redirect($location, $temporarily = true) { if ($temporarily) { $this->setStatus(302, 'Temporarily Moved'); } else { $this->setStatus(301, 'Permanently Moved'); }
php
{ "resource": "" }
q5389
Response.setContent
train
public function setContent($content) { $context = $this->_context;
php
{ "resource": "" }
q5390
Response.setJsonContent
train
public function setJsonContent($content) { $context = $this->_context; $this->setHeader('Content-Type', 'application/json; charset=utf-8'); if (is_array($content)) { if (!isset($content['code'])) { $content = ['code' => 0, 'message' => '', 'data' => $content]; } } elseif ($content instanceof \JsonSerializable) { $content = ['code' => 0, 'message' => '', 'data' => $content]; } elseif (is_string($content)) { null; } elseif (is_int($content)) { $content = ['code' => $content, 'message' => '']; } elseif ($content === null) { $content = ['code' => 0, 'message' => '', 'data' => null]; } elseif ($content instanceof ValidatorException) {
php
{ "resource": "" }
q5391
FileGarbageCollectorCommand._checkForFile
train
protected function _checkForFile($directory, $file) { //szukamy tylko plików w przedziale 33 - 37 znaków if (strlen($file) < 33 || strlen($file) > 37) { echo $file . "\n"; return; } //brak pliku w plikach CMS if (null === $fr = (new \Cms\Orm\CmsFileQuery) ->whereName()->equals($file) ->findFirst() ) { $this->_size
php
{ "resource": "" }
q5392
FiddlerController.webCommand
train
public function webCommand($id = '', $ip = '') { $options = []; if ($id) { $options['id'] = $id; } if ($ip) {
php
{ "resource": "" }
q5393
FiddlerController.cliCommand
train
public function cliCommand($id = '') { $options = []; if ($id) { $options['id'] = $id;
php
{ "resource": "" }
q5394
Parser.register_node_class
train
function register_node_class( $s, $class ){ if( ! class_exists($class) ){ $s = $this->token_name( $s );
php
{ "resource": "" }
q5395
Parser.create_node
train
function create_node( $s ){ if( isset($this->node_classes[$s]) ){ // custom node class $class =
php
{ "resource": "" }
q5396
Parser.token_name
train
function token_name ( $t ){ $t = self::token_to_symbol( $t ); if( ! is_int($t) ){
php
{ "resource": "" }
q5397
Parser.current_token
train
protected function current_token(){ if( !isset($this->tok) ){ $this->tok = current( $this->input ); $this->t =
php
{ "resource": "" }
q5398
Parser.next_token
train
protected function next_token(){ $this->tok = next( $this->input ); $this->t
php
{ "resource": "" }
q5399
Parser.prev_token
train
protected function prev_token(){ $this->tok = prev( $this->input ); $this->t
php
{ "resource": "" }