_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q21800 | Config.get | train | public function get($name, $default = null)
{
$keys = explode('.', $name);
$lastBranch = $this->loadConfig();
foreach ($keys as $keyName) {
if (isset($lastBranch[$keyName]) && (is_array($lastBranch) || is_object($lastBranch))) {
if (is_array($lastBranch)) {
... | php | {
"resource": ""
} |
q21801 | Config.has | train | public function has($name)
{
$keys = explode('.', $name);
$lastBranch = $this->loadConfig();
foreach ($keys as $keyName) {
if (isset($lastBranch[$keyName]) && (is_array($lastBranch) || is_object($lastBranch))) {
if (is_array($lastBranch)) {
$l... | php | {
"resource": ""
} |
q21802 | Config.set | train | public function set($name, $value = null, $dontMarkDirty = false)
{
if (is_object($name)) {
$name = get_object_vars($name);
}
if (!is_array($name)) {
$name = array($name => $value);
}
foreach ($name as $key => $value) {
if (in_array($key,... | php | {
"resource": ""
} |
q21803 | Config.remove | train | public function remove($name)
{
if (array_key_exists($name, $this->data)) {
unset($this->data[$name]);
$this->removeData[] = $name;
return true;
}
return null;
} | php | {
"resource": ""
} |
q21804 | Config.updateCacheTimestamp | train | public function updateCacheTimestamp($onlyValue = false)
{
$timestamp = [
$this->cacheTimestamp => time()
];
if ($onlyValue) {
return $timestamp;
}
return $this->set($timestamp);
} | php | {
"resource": ""
} |
q21805 | Install.run | train | public function run($data)
{
$processId = $data['id'];
$GLOBALS['log']->debug('Installation process ['.$processId.']: start run.');
if (empty($processId)) {
throw new Error('Installation package ID was not specified.');
}
$this->setProcessId($processId);
... | php | {
"resource": ""
} |
q21806 | Schema.initRebuildActions | train | protected function initRebuildActions($currentSchema = null, $metadataSchema = null)
{
$methods = array('beforeRebuild', 'afterRebuild');
$this->getClassParser()->setAllowedMethods($methods);
$rebuildActions = $this->getClassParser()->getData($this->rebuildActionsPath);
$classes = ... | php | {
"resource": ""
} |
q21807 | Schema.executeRebuildActions | train | protected function executeRebuildActions($action = 'beforeRebuild')
{
if (!isset($this->rebuildActionClasses)) {
$this->initRebuildActions();
}
if (isset($this->rebuildActionClasses[$action])) {
foreach ($this->rebuildActionClasses[$action] as $rebuildActionClass) {
... | php | {
"resource": ""
} |
q21808 | Converter.prepareManyMany | train | protected function prepareManyMany($entityName, $relationParams, $tables)
{
$tableName = Util::toUnderScore($relationParams['relationName']);
if ($this->getSchema()->hasTable($tableName)) {
$GLOBALS['log']->debug('DBAL: Table ['.$tableName.'] exists.');
return $this->getSche... | php | {
"resource": ""
} |
q21809 | Util.toCamelCase | train | public static function toCamelCase($name, $symbol = '_', $capitaliseFirstChar = false)
{
if (is_array($name)) {
foreach ($name as &$value) {
$value = static::toCamelCase($value, $symbol, $capitaliseFirstChar);
}
return $name;
}
$name = lc... | php | {
"resource": ""
} |
q21810 | Util.fromCamelCase | train | public static function fromCamelCase($name, $symbol = '_')
{
if (is_array($name)) {
foreach ($name as &$value) {
$value = static::fromCamelCase($value, $symbol);
}
return $name;
}
$name[0] = strtolower($name[0]);
return preg_repla... | php | {
"resource": ""
} |
q21811 | Util.unsetInArrayByValue | train | public static function unsetInArrayByValue($needle, array $haystack, $reIndex = true)
{
$doReindex = false;
foreach($haystack as $key => $value) {
if (is_array($value)) {
$haystack[$key] = static::unsetInArrayByValue($needle, $value);
} else if ($needle === $... | php | {
"resource": ""
} |
q21812 | Util.concatPath | train | public static function concatPath($folderPath, $filePath = null)
{
if (is_array($folderPath)) {
$fullPath = '';
foreach ($folderPath as $path) {
$fullPath = static::concatPath($fullPath, $path);
}
return static::fixPath($fullPath);
}
... | php | {
"resource": ""
} |
q21813 | Util.objectToArray | train | public static function objectToArray($object)
{
if (is_object($object)) {
$object = (array) $object;
}
return is_array($object) ? array_map("static::objectToArray", $object) : $object;
} | php | {
"resource": ""
} |
q21814 | Util.normilizeScopeName | train | public static function normilizeScopeName($name)
{
foreach (self::$reservedWordList as $reservedWord) {
if ($reservedWord.'Obj' == $name) {
return $reservedWord;
}
}
return $name;
} | php | {
"resource": ""
} |
q21815 | Util.getNaming | train | public static function getNaming($name, $prePostFix, $type = 'prefix', $symbol = '_')
{
if ($type == 'prefix') {
return static::toCamelCase($prePostFix.$symbol.$name, $symbol);
} else if ($type == 'postfix') {
return static::toCamelCase($name.$symbol.$prePostFix, $symbol);
... | php | {
"resource": ""
} |
q21816 | Util.unsetInArray | train | public static function unsetInArray(array $content, $unsets, $unsetParentEmptyArray = false)
{
if (empty($unsets)) {
return $content;
}
if (is_string($unsets)) {
$unsets = (array) $unsets;
}
foreach ($unsets as $rootKey => $unsetItem) {
$... | php | {
"resource": ""
} |
q21817 | Util.getClassName | train | public static function getClassName($filePath)
{
$className = preg_replace('/\.php$/i', '', $filePath);
$className = preg_replace('/^(application|custom)(\/|\\\)/i', '', $className);
$className = '\\'.static::toFormat($className, '\\');
return $className;
} | php | {
"resource": ""
} |
q21818 | Util.isEquals | train | public static function isEquals($var1, $var2)
{
if (is_array($var1)) {
static::ksortRecursive($var1);
}
if (is_array($var2)) {
static::ksortRecursive($var2);
}
return ($var1 === $var2);
} | php | {
"resource": ""
} |
q21819 | Util.ksortRecursive | train | public static function ksortRecursive(&$array)
{
if (!is_array($array)) {
return false;
}
ksort($array);
foreach ($array as $key => $value) {
static::ksortRecursive($array[$key]);
}
return true;
} | php | {
"resource": ""
} |
q21820 | Util.arrayDiff | train | public static function arrayDiff(array $array1, array $array2)
{
$diff = array();
foreach ($array1 as $key1 => $value1) {
if (array_key_exists($key1, $array2)) {
if ($value1 !== $array2[$key1]) {
$diff[$key1] = $array2[$key1];
}
... | php | {
"resource": ""
} |
q21821 | Util.fillArrayKeys | train | public static function fillArrayKeys($keys, $value)
{
$arrayKeys = is_array($keys) ? $keys : explode('.', $keys);
$array = array();
foreach (array_reverse($arrayKeys) as $i => $key) {
$array = array(
$key => ($i == 0) ? $value : $array,
);
}
... | php | {
"resource": ""
} |
q21822 | DataManager.rebuild | train | public function rebuild($entityList = null)
{
$this->populateConfigParameters();
$result = $this->clearCache();
$result &= $this->rebuildMetadata();
$result &= $this->rebuildDatabase($entityList);
$this->rebuildScheduledJobs();
return $result;
} | php | {
"resource": ""
} |
q21823 | DataManager.clearCache | train | public function clearCache()
{
$result = $this->getContainer()->get('fileManager')->removeInDir($this->cachePath);
if ($result != true) {
throw new Exceptions\Error("Error while clearing cache");
}
$this->updateCacheTimestamp();
return $result;
} | php | {
"resource": ""
} |
q21824 | Permission.setDefaultPermissions | train | public function setDefaultPermissions($path, $recurse = false)
{
if (!file_exists($path)) {
return false;
}
$permission = $this->getDefaultPermissions();
$result = $this->chmod($path, array($permission['file'], $permission['dir']), $recurse);
if (!empty($permiss... | php | {
"resource": ""
} |
q21825 | Permission.getCurrentPermission | train | public function getCurrentPermission($filePath)
{
if (!file_exists($filePath)) {
return false;
}
$fileInfo= stat($filePath);
return substr(base_convert($fileInfo['mode'],10,8), -4);
} | php | {
"resource": ""
} |
q21826 | Permission.chown | train | public function chown($path, $user = '', $recurse = false)
{
if (!file_exists($path)) {
return false;
}
if (empty($user)) {
$user = $this->getDefaultOwner();
}
//Set chown for non-recursive request
if (!$recurse) {
return $this->c... | php | {
"resource": ""
} |
q21827 | Permission.chownRecurse | train | protected function chownRecurse($path, $user)
{
if (!file_exists($path)) {
return false;
}
if (!is_dir($path)) {
return $this->chownReal($path, $user);
}
$result = $this->chownReal($path, $user);
$allFiles = $this->getFileManager()->getFileL... | php | {
"resource": ""
} |
q21828 | Permission.chgrp | train | public function chgrp($path, $group = null, $recurse = false)
{
if (!file_exists($path)) {
return false;
}
if (!isset($group)) {
$group = $this->getDefaultGroup();
}
//Set chgrp for non-recursive request
if (!$recurse) {
return $t... | php | {
"resource": ""
} |
q21829 | Permission.chgrpRecurse | train | protected function chgrpRecurse($path, $group) {
if (!file_exists($path)) {
return false;
}
if (!is_dir($path)) {
return $this->chgrpReal($path, $group);
}
$result = $this->chgrpReal($path, $group);
$allFiles = $this->getFileManager()->getFileL... | php | {
"resource": ""
} |
q21830 | Permission.getDefaultOwner | train | public function getDefaultOwner($usePosix = false)
{
$defaultPermissions = $this->getDefaultPermissions();
$owner = $defaultPermissions['user'];
if (empty($owner) && $usePosix) {
$owner = function_exists('posix_getuid') ? posix_getuid() : null;
}
if (empty($owne... | php | {
"resource": ""
} |
q21831 | Permission.getDefaultGroup | train | public function getDefaultGroup($usePosix = false)
{
$defaultPermissions = $this->getDefaultPermissions();
$group = $defaultPermissions['group'];
if (empty($group) && $usePosix) {
$group = function_exists('posix_getegid') ? posix_getegid() : null;
}
if (empty($g... | php | {
"resource": ""
} |
q21832 | Permission.setMapPermission | train | public function setMapPermission($mode = null)
{
$this->permissionError = array();
$this->permissionErrorRules = array();
$params = $this->getParams();
$permissionRules = $this->permissionRules;
if (isset($mode)) {
foreach ($permissionRules as &$value) {
... | php | {
"resource": ""
} |
q21833 | Permission.getSearchCount | train | protected function getSearchCount($search, array $array)
{
$search = $this->getPregQuote($search);
$number = 0;
foreach ($array as $value) {
if (preg_match('/^'.$search.'/', $value)) {
$number++;
}
}
return $number;
} | php | {
"resource": ""
} |
q21834 | FieldManager.normalizeDefs | train | protected function normalizeDefs($scope, $fieldName, array $fieldDefs)
{
$defs = new \stdClass();
$normalizedFieldDefs = $this->prepareFieldDefs($scope, $fieldName, $fieldDefs);
if (!empty($normalizedFieldDefs)) {
$defs->fields = (object) array(
$fieldName => (o... | php | {
"resource": ""
} |
q21835 | FieldManager.isCore | train | protected function isCore($scope, $name)
{
$existingField = $this->getFieldDefs($scope, $name);
if (isset($existingField) && (!isset($existingField['isCustom']) || !$existingField['isCustom'])) {
return true;
}
return false;
} | php | {
"resource": ""
} |
q21836 | ClassParser.getData | train | public function getData($paths, $cacheFile = false)
{
$data = null;
if (is_string($paths)) {
$paths = array(
'corePath' => $paths,
);
}
if ($cacheFile && file_exists($cacheFile) && $this->getConfig()->get('useCache')) {
$data = $t... | php | {
"resource": ""
} |
q21837 | AdminNotificationManager.createNotification | train | public function createNotification($message, $userId = '1')
{
$notification = $this->getEntityManager()->getEntity('Notification');
$notification->set(array(
'type' => 'message',
'data' => array(
'userId' => $userId,
),
'userId' => $use... | php | {
"resource": ""
} |
q21838 | Metadata.getData | train | protected function getData()
{
if (empty($this->data) || !is_array($this->data)) {
$this->init();
}
return $this->data;
} | php | {
"resource": ""
} |
q21839 | Metadata.getAll | train | public function getAll($isJSON = false, $reload = false)
{
if ($reload) {
$this->init($reload);
}
if ($isJSON) {
return Json::encode($this->data);
}
return $this->data;
} | php | {
"resource": ""
} |
q21840 | Metadata.getObjects | train | public function getObjects($key = null, $default = null)
{
$objData = $this->getObjData();
return Util::getValueByKey($objData, $key, $default);
} | php | {
"resource": ""
} |
q21841 | Metadata.getCustom | train | public function getCustom($key1, $key2, $default = null)
{
$filePath = array($this->paths['customPath'], $key1, $key2.'.json');
$fileContent = $this->getFileManager()->getContents($filePath);
if ($fileContent) {
return Json::decode($fileContent);
}
return $defau... | php | {
"resource": ""
} |
q21842 | Metadata.delete | train | public function delete($key1, $key2, $unsets = null)
{
if (!is_array($unsets)) {
$unsets = (array) $unsets;
}
switch ($key1) {
case 'entityDefs':
//unset related additional fields, e.g. a field with "address" type
$fieldDefinitionList ... | php | {
"resource": ""
} |
q21843 | Metadata.undelete | train | protected function undelete($key1, $key2, $data)
{
if (isset($this->deletedData[$key1][$key2])) {
foreach ($this->deletedData[$key1][$key2] as $unsetIndex => $unsetItem) {
$value = Util::getValueByKey($data, $unsetItem);
if (isset($value)) {
un... | php | {
"resource": ""
} |
q21844 | Metadata.getEntityPath | train | public function getEntityPath($entityName, $delim = '\\')
{
$path = $this->getScopePath($entityName, $delim);
return implode($delim, array($path, 'Entities', Util::normilizeClassName(ucfirst($entityName))));
} | php | {
"resource": ""
} |
q21845 | Job.removePendingJobDuplicates | train | public function removePendingJobDuplicates()
{
$pdo = $this->getEntityManager()->getPDO();
$query = "
SELECT scheduled_job_id
FROM job
WHERE
scheduled_job_id IS NOT NULL AND
`status` = '".CronManager::PENDING."' AND
... | php | {
"resource": ""
} |
q21846 | Job.updateFailedJobAttempts | train | public function updateFailedJobAttempts()
{
$query = "
SELECT * FROM job
WHERE
`status` = '" . CronManager::FAILED . "' AND
deleted = 0 AND
execute_time <= '".date('Y-m-d H:i:s')."' AND
attempts > 0
";
$... | php | {
"resource": ""
} |
q21847 | Base.getEntityParams | train | protected function getEntityParams($entityName = null, $isOrmEntityDefs = false, $returns = null)
{
if (!isset($entityName)) {
$entityName = $this->getEntityName();
}
$entityDefs = $this->getDefs($isOrmEntityDefs);
if (isset($entityDefs[$entityName])) {
retu... | php | {
"resource": ""
} |
q21848 | Base.getFieldParams | train | protected function getFieldParams($fieldName = null, $entityName = null, $isOrmEntityDefs = false, $returns = null)
{
if (!isset($fieldName)) {
$fieldName = $this->getFieldName();
}
if (!isset($entityName)) {
$entityName = $this->getEntityName();
}
$e... | php | {
"resource": ""
} |
q21849 | Base.getLinkParams | train | protected function getLinkParams($linkName = null, $entityName = null, $isOrmEntityDefs = false, $returns = null)
{
if (!isset($linkName)) {
$linkName = $this->getLinkName();
}
if (!isset($entityName)) {
$entityName = $this->getEntityName();
}
$entity... | php | {
"resource": ""
} |
q21850 | Base.getForeignField | train | protected function getForeignField($name, $entityName)
{
$foreignField = $this->getMetadata()->get('entityDefs.'.$entityName.'.fields.'.$name);
if ($foreignField['type'] != 'varchar') {
if ($foreignField['type'] == 'personName') {
return array('first' . ucfirst($name), '... | php | {
"resource": ""
} |
q21851 | SystemHelper.getPermissionCommands | train | public function getPermissionCommands($path, $permissions = array('644', '755'), $isSudo = false, $isFile = null, $changeOwner = true)
{
if (is_string($path)) {
$path = array_fill(0, 2, $path);
}
list($chmodPath, $chownPath) = $path;
$commands = array();
$command... | php | {
"resource": ""
} |
q21852 | Manager.getFileList | train | public function getFileList($path, $recursively = false, $filter = '', $onlyFileType = null, $isReturnSingleArray = false)
{
$path = $this->concatPaths($path);
$result = array();
if (!file_exists($path) || !is_dir($path)) {
return $result;
}
$cdir = scandir($pa... | php | {
"resource": ""
} |
q21853 | Manager.getSingeFileList | train | protected function getSingeFileList(array $fileList, $onlyFileType = null, $basePath = null, $parentDirName = '')
{
$singleFileList = array();
foreach($fileList as $dirName => $fileName) {
if (is_array($fileName)) {
$currentDir = Utils\Util::concatPath($parentDirName, $d... | php | {
"resource": ""
} |
q21854 | Manager.getPhpContents | train | public function getPhpContents($path)
{
$fullPath = $this->concatPaths($path);
if (file_exists($fullPath) && strtolower(substr($fullPath, -4)) == '.php') {
$phpContents = include($fullPath);
return $phpContents;
}
return false;
} | php | {
"resource": ""
} |
q21855 | Manager.putContents | train | public function putContents($path, $data, $flags = 0)
{
$fullPath = $this->concatPaths($path); //todo remove after changing the params
if ($this->checkCreateFile($fullPath) === false) {
throw new Error('Permission denied for '. $fullPath);
}
$res = (file_put_contents($f... | php | {
"resource": ""
} |
q21856 | Manager.putPhpContents | train | public function putPhpContents($path, $data, $withObjects = false)
{
return $this->putContents($path, $this->wrapForDataExport($data, $withObjects), LOCK_EX);
} | php | {
"resource": ""
} |
q21857 | Manager.putContentsJson | train | public function putContentsJson($path, $data)
{
if (!Utils\Json::isJSON($data)) {
$data = Utils\Json::encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
}
return $this->putContents($path, $data, LOCK_EX);
} | php | {
"resource": ""
} |
q21858 | Manager.mergeContents | train | public function mergeContents($path, $content, $isReturnJson = false, $removeOptions = null, $isPhp = false)
{
if ($isPhp) {
$fileContent = $this->getPhpContents($path);
} else {
$fileContent = $this->getContents($path);
}
$fullPath = $this->concatPaths($path... | php | {
"resource": ""
} |
q21859 | Manager.mergePhpContents | train | public function mergePhpContents($path, $content, $removeOptions = null)
{
return $this->mergeContents($path, $content, false, $removeOptions, true);
} | php | {
"resource": ""
} |
q21860 | Manager.unsetContents | train | public function unsetContents($path, $unsets, $isJSON = true)
{
$currentData = $this->getContents($path);
if (!isset($currentData) || !$currentData) {
return true;
}
$currentDataArray = Utils\Json::getArrayData($currentData);
$unsettedData = Utils\Util::unsetInA... | php | {
"resource": ""
} |
q21861 | Manager.mkdir | train | public function mkdir($path, $permission = null, $recursive = false)
{
$fullPath = $this->concatPaths($path);
if (file_exists($fullPath) && is_dir($path)) {
return true;
}
$defaultPermissions = $this->getPermissionUtils()->getDefaultPermissions();
if (!isset($p... | php | {
"resource": ""
} |
q21862 | Manager.checkCreateFile | train | public function checkCreateFile($filePath)
{
$defaultPermissions = $this->getPermissionUtils()->getDefaultPermissions();
if (file_exists($filePath)) {
if (!is_writable($filePath) && !in_array($this->getPermissionUtils()->getCurrentPermission($filePath), array($defaultPermissions['file']... | php | {
"resource": ""
} |
q21863 | Manager.removeInDir | train | public function removeInDir($dirPath, $removeWithDir = false)
{
$fileList = $this->getFileList($dirPath, false);
$result = true;
if (is_array($fileList)) {
foreach ($fileList as $file) {
$fullPath = Utils\Util::concatPath($dirPath, $file);
if (is_... | php | {
"resource": ""
} |
q21864 | Manager.removeEmptyDirs | train | protected function removeEmptyDirs($path)
{
$parentDirName = $this->getParentDirName($path);
$res = true;
if ($this->isDirEmpty($parentDirName)) {
$res &= $this->rmdir($parentDirName);
$res &= $this->removeEmptyDirs($parentDirName);
}
return (bool) $... | php | {
"resource": ""
} |
q21865 | Manager.isDirEmpty | train | public function isDirEmpty($path)
{
if (is_dir($path)) {
$fileList = $this->getFileList($path, true);
if (is_array($fileList) && empty($fileList)) {
return true;
}
}
return false;
} | php | {
"resource": ""
} |
q21866 | Manager.getFileName | train | public function getFileName($fileName, $ext='')
{
if (empty($ext)) {
$fileName= substr($fileName, 0, strrpos($fileName, '.', -1));
}
else {
if (substr($ext, 0, 1)!='.') {
$ext= '.'.$ext;
}
if (substr($fileName, -(strlen($ext)))... | php | {
"resource": ""
} |
q21867 | Manager.getDirName | train | public function getDirName($path, $isFullPath = true, $useIsDir = true)
{
$dirName = preg_replace('/\/$/i', '', $path);
$dirName = ($useIsDir && is_dir($dirName)) ? $dirName : pathinfo($dirName, PATHINFO_DIRNAME);
if (!$isFullPath) {
$pieces = explode('/', $dirName);
... | php | {
"resource": ""
} |
q21868 | Manager.wrapForDataExport | train | public function wrapForDataExport($content, $withObjects = false)
{
if (!isset($content)) {
return false;
}
if (!$withObjects) {
return "<?php\n".
"return " . var_export($content, true) . ";\n".
"?>";
} else {
return "<?php... | php | {
"resource": ""
} |
q21869 | Helper.getIdFor | train | public static function getIdFor($object, $type)
{
if (is_null($object)) {
return null;
} elseif (is_object($object)) {
return $object->getKey();
} elseif (is_array($object)) {
return $object['id'];
} elseif (is_numeric($object)) {
retur... | php | {
"resource": ""
} |
q21870 | Helper.fetchTeam | train | public static function fetchTeam($team = null)
{
if (is_null($team) || !Config::get('laratrust.use_teams')) {
return null;
}
return static::getIdFor($team, 'team');
} | php | {
"resource": ""
} |
q21871 | Helper.assignRealValuesTo | train | public static function assignRealValuesTo($team, $requireAllOrOptions, $method)
{
return [
($method($team) ? null : $team),
($method($team) ? $team : $requireAllOrOptions),
];
} | php | {
"resource": ""
} |
q21872 | Helper.standardize | train | public static function standardize($value, $toArray = false)
{
if (is_array($value) || ((strpos($value, '|') === false) && !$toArray)) {
return $value;
}
return explode('|', $value);
} | php | {
"resource": ""
} |
q21873 | Helper.isInSameTeam | train | public static function isInSameTeam($rolePermission, $team)
{
if (
!Config::get('laratrust.use_teams')
|| (!Config::get('laratrust.teams_strict_check') && is_null($team))
) {
return true;
}
$teamForeignKey = static::teamForeignKey();
retu... | php | {
"resource": ""
} |
q21874 | Helper.checkOrSet | train | public static function checkOrSet($option, $array, $possibleValues)
{
if (!isset($array[$option])) {
$array[$option] = $possibleValues[0];
return $array;
}
$ignoredOptions = ['team', 'foreignKeyName'];
if (!in_array($option, $ignoredOptions) && !in_array($a... | php | {
"resource": ""
} |
q21875 | Helper.hidrateModel | train | public static function hidrateModel($class, $data)
{
if ($data instanceof Model) {
return $data;
}
if (!isset($data['pivot'])) {
throw new \Exception("The 'pivot' attribute in the {$class} is hidden");
}
$model = new $class;
$primaryKey = $mo... | php | {
"resource": ""
} |
q21876 | Helper.getPermissionWithAndWithoutWildcards | train | public static function getPermissionWithAndWithoutWildcards($permissions)
{
$wildcard = [];
$noWildcard = [];
foreach ($permissions as $permission) {
if (strpos($permission, '*') === false) {
$noWildcard[] = $permission;
} else {
$wild... | php | {
"resource": ""
} |
q21877 | LaratrustRoleTrait.bootLaratrustRoleTrait | train | public static function bootLaratrustRoleTrait()
{
$flushCache = function ($role) {
$role->flushCache();
};
// If the role doesn't use SoftDeletes.
if (method_exists(static::class, 'restored')) {
static::restored($flushCache);
}
static::delete... | php | {
"resource": ""
} |
q21878 | LaratrustRoleTrait.permissions | train | public function permissions()
{
return $this->belongsToMany(
Config::get('laratrust.models.permission'),
Config::get('laratrust.tables.permission_role'),
Config::get('laratrust.foreign_keys.role'),
Config::get('laratrust.foreign_keys.permission')
);
... | php | {
"resource": ""
} |
q21879 | LaratrustRoleTrait.detachPermissions | train | public function detachPermissions($permissions = null)
{
if (!$permissions) {
$permissions = $this->permissions()->get();
}
foreach ($permissions as $permission) {
$this->detachPermission($permission);
}
return $this;
} | php | {
"resource": ""
} |
q21880 | LaratrustTeamTrait.bootLaratrustTeamTrait | train | public static function bootLaratrustTeamTrait()
{
static::deleting(function ($team) {
if (method_exists($team, 'bootSoftDeletes') && !$team->forceDeleting) {
return;
}
foreach (array_keys(Config::get('laratrust.user_models')) as $key) {
$t... | php | {
"resource": ""
} |
q21881 | Laratrust.hasRole | train | public function hasRole($role, $team = null, $requireAll = false)
{
if ($user = $this->user()) {
return $user->hasRole($role, $team, $requireAll);
}
return false;
} | php | {
"resource": ""
} |
q21882 | Laratrust.ability | train | public function ability($roles, $permissions, $team = null, $options = [])
{
if ($user = $this->user()) {
return $user->ability($roles, $permissions, $team, $options);
}
return false;
} | php | {
"resource": ""
} |
q21883 | LaratrustHasScopes.scopeWherePermissionIs | train | public function scopeWherePermissionIs($query, $permission = '', $boolean = 'and')
{
$method = $boolean == 'and' ? 'where' : 'orWhere';
return $query->$method(function ($query) use ($permission) {
$query->whereHas('roles.permissions', function ($permissionQuery) use ($permission) {
... | php | {
"resource": ""
} |
q21884 | LaratrustHasEvents.laratrustObserve | train | public static function laratrustObserve($class)
{
$className = is_string($class) ? $class : get_class($class);
foreach (self::$laratrustObservables as $event) {
if (method_exists($class, $event)) {
static::registerLaratrustEvent(Str::snake($event, '.'), $className.'@'.$e... | php | {
"resource": ""
} |
q21885 | LaratrustServiceProvider.registerMiddlewares | train | protected function registerMiddlewares()
{
if (!$this->app['config']->get('laratrust.middleware.register')) {
return;
}
$router = $this->app['router'];
if (method_exists($router, 'middleware')) {
$registerMethod = 'middleware';
} elseif (method_exist... | php | {
"resource": ""
} |
q21886 | LaratrustUserDefaultChecker.userCachedRoles | train | protected function userCachedRoles()
{
$cacheKey = 'laratrust_roles_for_user_' . $this->user->getKey();
if (!Config::get('laratrust.cache.enabled')) {
return $this->user->roles()->get();
}
return Cache::remember($cacheKey, Config::get('laratrust.cache.expiration_time', ... | php | {
"resource": ""
} |
q21887 | LaratrustUserDefaultChecker.userCachedPermissions | train | public function userCachedPermissions()
{
$cacheKey = 'laratrust_permissions_for_user_' . $this->user->getKey();
if (!Config::get('laratrust.cache.enabled')) {
return $this->user->permissions()->get();
}
return Cache::remember($cacheKey, Config::get('laratrust.cache.exp... | php | {
"resource": ""
} |
q21888 | LaratrustPermissionTrait.bootLaratrustPermissionTrait | train | public static function bootLaratrustPermissionTrait()
{
static::deleting(function ($permission) {
if (!method_exists(Config::get('laratrust.models.permission'), 'bootSoftDeletes')) {
$permission->roles()->sync([]);
}
});
static::deleting(function ($pe... | php | {
"resource": ""
} |
q21889 | LaratrustPermissionTrait.roles | train | public function roles()
{
return $this->belongsToMany(
Config::get('laratrust.models.role'),
Config::get('laratrust.tables.permission_role'),
Config::get('laratrust.foreign_keys.permission'),
Config::get('laratrust.foreign_keys.role')
);
} | php | {
"resource": ""
} |
q21890 | LaratrustPermissionTrait.getMorphByUserRelation | train | public function getMorphByUserRelation($relationship)
{
return $this->morphedByMany(
Config::get('laratrust.user_models')[$relationship],
'user',
Config::get('laratrust.tables.permission_user'),
Config::get('laratrust.foreign_keys.permission'),
Con... | php | {
"resource": ""
} |
q21891 | LaratrustRoleDefaultChecker.currentRoleCachedPermissions | train | public function currentRoleCachedPermissions()
{
$cacheKey = 'laratrust_permissions_for_role_' . $this->role->getKey();
if (!Config::get('laratrust.cache.enabled')) {
return $this->role->permissions()->get();
}
return Cache::remember($cacheKey, Config::get('laratrust.ca... | php | {
"resource": ""
} |
q21892 | LaratrustRegistersBladeDirectives.handle | train | public function handle($laravelVersion = '5.3.0')
{
if (version_compare(strtolower($laravelVersion), '5.3.0-dev', '>=')) {
$this->registerWithParenthesis();
} else {
$this->registerWithoutParenthesis();
}
$this->registerClosingDirectives();
} | php | {
"resource": ""
} |
q21893 | LaratrustRegistersBladeDirectives.registerWithParenthesis | train | protected function registerWithParenthesis()
{
// Call to Laratrust::hasRole.
Blade::directive('role', function ($expression) {
return "<?php if (app('laratrust')->hasRole({$expression})) : ?>";
});
// Call to Laratrust::can.
Blade::directive('permission', functi... | php | {
"resource": ""
} |
q21894 | LaratrustRegistersBladeDirectives.registerWithoutParenthesis | train | protected function registerWithoutParenthesis()
{
// Call to Laratrust::hasRole.
Blade::directive('role', function ($expression) {
return "<?php if (app('laratrust')->hasRole{$expression}) : ?>";
});
// Call to Laratrust::can.
Blade::directive('permission', funct... | php | {
"resource": ""
} |
q21895 | LaratrustMiddleware.authorization | train | protected function authorization($type, $rolesPermissions, $team, $options)
{
list($team, $requireAll, $guard) = $this->assignRealValuesTo($team, $options);
$method = $type == 'roles' ? 'hasRole' : 'hasPermission';
if (!is_array($rolesPermissions)) {
$rolesPermissions = explode(... | php | {
"resource": ""
} |
q21896 | LaratrustMiddleware.assignRealValuesTo | train | protected function assignRealValuesTo($team, $options)
{
return [
(Str::contains($team, ['require_all', 'guard:']) ? null : $team),
(Str::contains($team, 'require_all') ?: Str::contains($options, 'require_all')),
(Str::contains($team, 'guard:') ? $this->extractGuard($team... | php | {
"resource": ""
} |
q21897 | LaratrustMiddleware.extractGuard | train | protected function extractGuard($string)
{
$options = Collection::make(explode('|', $string));
return $options->reject(function ($option) {
return strpos($option, 'guard:') === false;
})->map(function ($option) {
return explode(':', $option)[1];
})->first();
... | php | {
"resource": ""
} |
q21898 | UpgradeCommand.getExistingMigrationsWarning | train | protected function getExistingMigrationsWarning(array $existingMigrations)
{
if (count($existingMigrations) > 1) {
$base = "Laratrust upgrade migrations already exist.\nFollowing files were found: ";
} else {
$base = "Laratrust upgrade migration already exists.\nFollowing fil... | php | {
"resource": ""
} |
q21899 | UpgradeCommand.alreadyExistingMigrations | train | protected function alreadyExistingMigrations()
{
$matchingFiles = glob($this->getMigrationPath('*'));
return array_map(function ($path) {
return basename($path);
}, $matchingFiles);
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.