repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
hiqdev/hidev
src/base/File.php
File.create
public static function create($path) { $config = is_array($path) ? $path : compact('path'); $config['class'] = get_called_class(); return Yii::createObject($config); }
php
public static function create($path) { $config = is_array($path) ? $path : compact('path'); $config['class'] = get_called_class(); return Yii::createObject($config); }
[ "public", "static", "function", "create", "(", "$", "path", ")", "{", "$", "config", "=", "is_array", "(", "$", "path", ")", "?", "$", "path", ":", "compact", "(", "'path'", ")", ";", "$", "config", "[", "'class'", "]", "=", "get_called_class", "(", ...
Create file object. @param string|array $path or config @return File
[ "Create", "file", "object", "." ]
ac089c8307f68ff7afc2876caa0b6625dd9eb5c7
https://github.com/hiqdev/hidev/blob/ac089c8307f68ff7afc2876caa0b6625dd9eb5c7/src/base/File.php#L94-L100
train
hiqdev/hidev
src/base/BinaryPhp.php
BinaryPhp.detectCommand
public function detectCommand($path) { $path = parent::detectCommand($path); return is_executable($path) ? $path : '/usr/bin/env php ' . $path; }
php
public function detectCommand($path) { $path = parent::detectCommand($path); return is_executable($path) ? $path : '/usr/bin/env php ' . $path; }
[ "public", "function", "detectCommand", "(", "$", "path", ")", "{", "$", "path", "=", "parent", "::", "detectCommand", "(", "$", "path", ")", ";", "return", "is_executable", "(", "$", "path", ")", "?", "$", "path", ":", "'/usr/bin/env php '", ".", "$", ...
Detect command execution string. @param mixed $path @return string
[ "Detect", "command", "execution", "string", "." ]
ac089c8307f68ff7afc2876caa0b6625dd9eb5c7
https://github.com/hiqdev/hidev/blob/ac089c8307f68ff7afc2876caa0b6625dd9eb5c7/src/base/BinaryPhp.php#L43-L48
train
hiqdev/hidev
src/components/GitHub.php
GitHub.createRepo
public function createRepo(string $repo = null) { $end = $this->getVendorType() === 'org' ?'/orgs/' . $this->getVendor() . '/repos' : '/user/repos' ; $res = $this->request('POST', $end, [ 'name' => $this->getName(), 'description' => $this->getDescription(), ]); if (Helper::isResponseOk($res)) { echo "\ngit remote add origin git@github.com:{$this->getFullName()}.git\n"; echo "git push -u origin master\n"; } return $res; }
php
public function createRepo(string $repo = null) { $end = $this->getVendorType() === 'org' ?'/orgs/' . $this->getVendor() . '/repos' : '/user/repos' ; $res = $this->request('POST', $end, [ 'name' => $this->getName(), 'description' => $this->getDescription(), ]); if (Helper::isResponseOk($res)) { echo "\ngit remote add origin git@github.com:{$this->getFullName()}.git\n"; echo "git push -u origin master\n"; } return $res; }
[ "public", "function", "createRepo", "(", "string", "$", "repo", "=", "null", ")", "{", "$", "end", "=", "$", "this", "->", "getVendorType", "(", ")", "===", "'org'", "?", "'/orgs/'", ".", "$", "this", "->", "getVendor", "(", ")", ".", "'/repos'", ":"...
Create the repo on GitHub. @return int exit code
[ "Create", "the", "repo", "on", "GitHub", "." ]
ac089c8307f68ff7afc2876caa0b6625dd9eb5c7
https://github.com/hiqdev/hidev/blob/ac089c8307f68ff7afc2876caa0b6625dd9eb5c7/src/components/GitHub.php#L111-L127
train
hiqdev/hidev
src/components/GitHub.php
GitHub.releaseRepo
public function releaseRepo($release = null) { $release = $this->take('version')->getRelease($release); $notes = $this->take('chkipper')->getReleaseNotes(); $wait = $this->waitPush(); if ($wait) { return $wait; } return $this->request('POST', '/repos/' . $this->getFull_name() . '/releases', [ 'tag_name' => $release, 'name' => $release, 'body' => $notes, ]); }
php
public function releaseRepo($release = null) { $release = $this->take('version')->getRelease($release); $notes = $this->take('chkipper')->getReleaseNotes(); $wait = $this->waitPush(); if ($wait) { return $wait; } return $this->request('POST', '/repos/' . $this->getFull_name() . '/releases', [ 'tag_name' => $release, 'name' => $release, 'body' => $notes, ]); }
[ "public", "function", "releaseRepo", "(", "$", "release", "=", "null", ")", "{", "$", "release", "=", "$", "this", "->", "take", "(", "'version'", ")", "->", "getRelease", "(", "$", "release", ")", ";", "$", "notes", "=", "$", "this", "->", "take", ...
Creates github release. @param string $release version number
[ "Creates", "github", "release", "." ]
ac089c8307f68ff7afc2876caa0b6625dd9eb5c7
https://github.com/hiqdev/hidev/blob/ac089c8307f68ff7afc2876caa0b6625dd9eb5c7/src/components/GitHub.php#L164-L178
train
mmoreram/RSQueueBundle
Factory/RedisFactory.php
RedisFactory.get
public function get() { $redis = new Redis; $redis->connect($this->config['host'], $this->config['port']); $redis->setOption(Redis::OPT_READ_TIMEOUT, -1); if ($this->config['database']) { $redis->select($this->config['database']); } return $redis; }
php
public function get() { $redis = new Redis; $redis->connect($this->config['host'], $this->config['port']); $redis->setOption(Redis::OPT_READ_TIMEOUT, -1); if ($this->config['database']) { $redis->select($this->config['database']); } return $redis; }
[ "public", "function", "get", "(", ")", "{", "$", "redis", "=", "new", "Redis", ";", "$", "redis", "->", "connect", "(", "$", "this", "->", "config", "[", "'host'", "]", ",", "$", "this", "->", "config", "[", "'port'", "]", ")", ";", "$", "redis",...
Generate new Predis instance @return \Redis instance
[ "Generate", "new", "Predis", "instance" ]
36ec5c43daf2c561c3137cee62a1d3c209996351
https://github.com/mmoreram/RSQueueBundle/blob/36ec5c43daf2c561c3137cee62a1d3c209996351/Factory/RedisFactory.php#L37-L47
train
mmoreram/RSQueueBundle
Factory/SerializerFactory.php
SerializerFactory.get
public function get() { if (class_exists($this->serializerType)) { if (in_array('Mmoreram\\RSQueueBundle\\Serializer\\Interfaces\\SerializerInterface', class_implements($this->serializerType))) { return new $this->serializerType; } else { throw new SerializerNotImplementsInterfaceException; } } $composedSerializerNamespace = '\\Mmoreram\\RSQueueBundle\\Serializer\\' . $this->serializerType . 'Serializer'; if (class_exists($composedSerializerNamespace)) { return new $composedSerializerNamespace; } throw new SerializerNotFoundException; }
php
public function get() { if (class_exists($this->serializerType)) { if (in_array('Mmoreram\\RSQueueBundle\\Serializer\\Interfaces\\SerializerInterface', class_implements($this->serializerType))) { return new $this->serializerType; } else { throw new SerializerNotImplementsInterfaceException; } } $composedSerializerNamespace = '\\Mmoreram\\RSQueueBundle\\Serializer\\' . $this->serializerType . 'Serializer'; if (class_exists($composedSerializerNamespace)) { return new $composedSerializerNamespace; } throw new SerializerNotFoundException; }
[ "public", "function", "get", "(", ")", "{", "if", "(", "class_exists", "(", "$", "this", "->", "serializerType", ")", ")", "{", "if", "(", "in_array", "(", "'Mmoreram\\\\RSQueueBundle\\\\Serializer\\\\Interfaces\\\\SerializerInterface'", ",", "class_implements", "(", ...
Generate new Serializer @return SerializerInterface Generated Serializer
[ "Generate", "new", "Serializer" ]
36ec5c43daf2c561c3137cee62a1d3c209996351
https://github.com/mmoreram/RSQueueBundle/blob/36ec5c43daf2c561c3137cee62a1d3c209996351/Factory/SerializerFactory.php#L44-L63
train
hiqdev/hidev
src/console/VersionController.php
VersionController.actionShow
public function actionShow($release = null) { $version = $this->getComponent(); $version->load(); $version->setRelease($release); $dir = dirname($version->getAbspath()); echo $version->renderFile() . PHP_EOL; echo "(run from $dir)\n"; }
php
public function actionShow($release = null) { $version = $this->getComponent(); $version->load(); $version->setRelease($release); $dir = dirname($version->getAbspath()); echo $version->renderFile() . PHP_EOL; echo "(run from $dir)\n"; }
[ "public", "function", "actionShow", "(", "$", "release", "=", "null", ")", "{", "$", "version", "=", "$", "this", "->", "getComponent", "(", ")", ";", "$", "version", "->", "load", "(", ")", ";", "$", "version", "->", "setRelease", "(", "$", "release...
Show current version. @param string $release
[ "Show", "current", "version", "." ]
ac089c8307f68ff7afc2876caa0b6625dd9eb5c7
https://github.com/hiqdev/hidev/blob/ac089c8307f68ff7afc2876caa0b6625dd9eb5c7/src/console/VersionController.php#L26-L34
train
mmoreram/RSQueueBundle
Collector/RSQueueCollector.php
RSQueueCollector.onProducerAction
public function onProducerAction(RSQueueProducerEvent $event) { $this->data['total']++; $this->data['prod'][] = array( 'payload' => $event->getPayloadSerialized(), 'queue' => $event->getQueueName(), 'alias' => $event->getQueueAlias(), ); return $this; }
php
public function onProducerAction(RSQueueProducerEvent $event) { $this->data['total']++; $this->data['prod'][] = array( 'payload' => $event->getPayloadSerialized(), 'queue' => $event->getQueueName(), 'alias' => $event->getQueueAlias(), ); return $this; }
[ "public", "function", "onProducerAction", "(", "RSQueueProducerEvent", "$", "event", ")", "{", "$", "this", "->", "data", "[", "'total'", "]", "++", ";", "$", "this", "->", "data", "[", "'prod'", "]", "[", "]", "=", "array", "(", "'payload'", "=>", "$"...
Subscribed to RSQueueProducer event. Add to collect data a new producer action @param RSQueueProducerEvent $event Event fired @return QueueCollector self Object
[ "Subscribed", "to", "RSQueueProducer", "event", "." ]
36ec5c43daf2c561c3137cee62a1d3c209996351
https://github.com/mmoreram/RSQueueBundle/blob/36ec5c43daf2c561c3137cee62a1d3c209996351/Collector/RSQueueCollector.php#L52-L62
train
mmoreram/RSQueueBundle
Collector/RSQueueCollector.php
RSQueueCollector.onPublisherAction
public function onPublisherAction(RSQueuePublisherEvent $event) { $this->data['total']++; $this->data['publ'][] = array( 'payload' => $event->getPayloadSerialized(), 'queue' => $event->getChannelName(), 'alias' => $event->getChannelAlias(), ); return $this; }
php
public function onPublisherAction(RSQueuePublisherEvent $event) { $this->data['total']++; $this->data['publ'][] = array( 'payload' => $event->getPayloadSerialized(), 'queue' => $event->getChannelName(), 'alias' => $event->getChannelAlias(), ); return $this; }
[ "public", "function", "onPublisherAction", "(", "RSQueuePublisherEvent", "$", "event", ")", "{", "$", "this", "->", "data", "[", "'total'", "]", "++", ";", "$", "this", "->", "data", "[", "'publ'", "]", "[", "]", "=", "array", "(", "'payload'", "=>", "...
Subscribed to RSQueuePublisher event. Add to collect data a new publisher action @param RSQueuePublisherEvent $event Event fired @return QueueCollector self Object
[ "Subscribed", "to", "RSQueuePublisher", "event", "." ]
36ec5c43daf2c561c3137cee62a1d3c209996351
https://github.com/mmoreram/RSQueueBundle/blob/36ec5c43daf2c561c3137cee62a1d3c209996351/Collector/RSQueueCollector.php#L73-L83
train
hiqdev/hidev
src/helpers/FileHelper.php
FileHelper.read
public static function read($path, $die = true) { $path = Yii::getAlias($path); if (is_readable($path)) { return file_get_contents($path); } $level = $die ? Logger::LEVEL_ERROR : Logger::LEVEL_WARNING; Yii::getLogger()->log('Failed to read file: ' . $path, $level, 'file'); return false; }
php
public static function read($path, $die = true) { $path = Yii::getAlias($path); if (is_readable($path)) { return file_get_contents($path); } $level = $die ? Logger::LEVEL_ERROR : Logger::LEVEL_WARNING; Yii::getLogger()->log('Failed to read file: ' . $path, $level, 'file'); return false; }
[ "public", "static", "function", "read", "(", "$", "path", ",", "$", "die", "=", "true", ")", "{", "$", "path", "=", "Yii", "::", "getAlias", "(", "$", "path", ")", ";", "if", "(", "is_readable", "(", "$", "path", ")", ")", "{", "return", "file_ge...
Reads and returns file content. @param string $path @return string|false false if can't read
[ "Reads", "and", "returns", "file", "content", "." ]
ac089c8307f68ff7afc2876caa0b6625dd9eb5c7
https://github.com/hiqdev/hidev/blob/ac089c8307f68ff7afc2876caa0b6625dd9eb5c7/src/helpers/FileHelper.php#L26-L38
train
hiqdev/hidev
src/helpers/FileHelper.php
FileHelper.write
public static function write($path, $content) { $path = Yii::getAlias($path); if (is_file($path) && file_get_contents($path) === $content) { return false; } static::mkdir(dirname($path)); try { file_put_contents($path, $content); } catch (\Exception $e) { if (posix_isatty(0)) { $tmp = tempnam('/tmp', 'hidev.'); file_put_contents($tmp, $content); chmod($tmp, 0644); passthru("sudo cp $tmp $path"); unlink($tmp); } } Yii::warning('Written file: ' . $path, 'file'); return true; }
php
public static function write($path, $content) { $path = Yii::getAlias($path); if (is_file($path) && file_get_contents($path) === $content) { return false; } static::mkdir(dirname($path)); try { file_put_contents($path, $content); } catch (\Exception $e) { if (posix_isatty(0)) { $tmp = tempnam('/tmp', 'hidev.'); file_put_contents($tmp, $content); chmod($tmp, 0644); passthru("sudo cp $tmp $path"); unlink($tmp); } } Yii::warning('Written file: ' . $path, 'file'); return true; }
[ "public", "static", "function", "write", "(", "$", "path", ",", "$", "content", ")", "{", "$", "path", "=", "Yii", "::", "getAlias", "(", "$", "path", ")", ";", "if", "(", "is_file", "(", "$", "path", ")", "&&", "file_get_contents", "(", "$", "path...
Writes given content to the file. Doesn't touch file if it has exactly same content. Creates intermediate directories when necessary. @param string $path @param string $content @return bool true if file was changed
[ "Writes", "given", "content", "to", "the", "file", ".", "Doesn", "t", "touch", "file", "if", "it", "has", "exactly", "same", "content", ".", "Creates", "intermediate", "directories", "when", "necessary", "." ]
ac089c8307f68ff7afc2876caa0b6625dd9eb5c7
https://github.com/hiqdev/hidev/blob/ac089c8307f68ff7afc2876caa0b6625dd9eb5c7/src/helpers/FileHelper.php#L48-L70
train
hiqdev/hidev
src/helpers/FileHelper.php
FileHelper.mkdir
public static function mkdir($path) { $path = Yii::getAlias($path); $path = rtrim(trim($path), '/'); if (!file_exists($path)) { mkdir($path, 0777, true); Yii::warning('Created dir: ' . $path . '/', 'file'); return true; } return false; }
php
public static function mkdir($path) { $path = Yii::getAlias($path); $path = rtrim(trim($path), '/'); if (!file_exists($path)) { mkdir($path, 0777, true); Yii::warning('Created dir: ' . $path . '/', 'file'); return true; } return false; }
[ "public", "static", "function", "mkdir", "(", "$", "path", ")", "{", "$", "path", "=", "Yii", "::", "getAlias", "(", "$", "path", ")", ";", "$", "path", "=", "rtrim", "(", "trim", "(", "$", "path", ")", ",", "'/'", ")", ";", "if", "(", "!", "...
Creates directory if not exists. Creates intermediate directories when necessary. @param string $path @return bool true if directory did not exist and was created
[ "Creates", "directory", "if", "not", "exists", ".", "Creates", "intermediate", "directories", "when", "necessary", "." ]
ac089c8307f68ff7afc2876caa0b6625dd9eb5c7
https://github.com/hiqdev/hidev/blob/ac089c8307f68ff7afc2876caa0b6625dd9eb5c7/src/helpers/FileHelper.php#L78-L90
train
hiqdev/hidev
src/helpers/FileHelper.php
FileHelper.symlink
public static function symlink($src, $dst) { try { // remove old link if (is_link($dst) && readlink($dst) !== $src) { unlink($dst); } if (!is_link($dst)) { return symlink($src, $dst); } } catch (\Exception $e) { if (posix_isatty(0)) { passthru("sudo ln -s $src $dst", $retval); return $retval === 0; } } }
php
public static function symlink($src, $dst) { try { // remove old link if (is_link($dst) && readlink($dst) !== $src) { unlink($dst); } if (!is_link($dst)) { return symlink($src, $dst); } } catch (\Exception $e) { if (posix_isatty(0)) { passthru("sudo ln -s $src $dst", $retval); return $retval === 0; } } }
[ "public", "static", "function", "symlink", "(", "$", "src", ",", "$", "dst", ")", "{", "try", "{", "// remove old link", "if", "(", "is_link", "(", "$", "dst", ")", "&&", "readlink", "(", "$", "dst", ")", "!==", "$", "src", ")", "{", "unlink", "(",...
Creates a symlink. @param string $src existing source path @param string $dst destionation path to be created @return true on success and false/null on failure
[ "Creates", "a", "symlink", "." ]
ac089c8307f68ff7afc2876caa0b6625dd9eb5c7
https://github.com/hiqdev/hidev/blob/ac089c8307f68ff7afc2876caa0b6625dd9eb5c7/src/helpers/FileHelper.php#L98-L117
train
ZF-Commons/ZfcUser
src/ZfcUser/Authentication/Storage/Db.php
Db.isEmpty
public function isEmpty() { if ($this->getStorage()->isEmpty()) { return true; } $identity = $this->getStorage()->read(); if ($identity === null) { $this->clear(); return true; } return false; }
php
public function isEmpty() { if ($this->getStorage()->isEmpty()) { return true; } $identity = $this->getStorage()->read(); if ($identity === null) { $this->clear(); return true; } return false; }
[ "public", "function", "isEmpty", "(", ")", "{", "if", "(", "$", "this", "->", "getStorage", "(", ")", "->", "isEmpty", "(", ")", ")", "{", "return", "true", ";", "}", "$", "identity", "=", "$", "this", "->", "getStorage", "(", ")", "->", "read", ...
Returns true if and only if storage is empty @throws \Zend\Authentication\Exception\InvalidArgumentException If it is impossible to determine whether storage is empty or not @return boolean
[ "Returns", "true", "if", "and", "only", "if", "storage", "is", "empty" ]
03c8d818807e5edf9cdc723a5460d6ed8ce9c550
https://github.com/ZF-Commons/ZfcUser/blob/03c8d818807e5edf9cdc723a5460d6ed8ce9c550/src/ZfcUser/Authentication/Storage/Db.php#L40-L52
train
ZF-Commons/ZfcUser
src/ZfcUser/Authentication/Storage/Db.php
Db.read
public function read() { if (null !== $this->resolvedIdentity) { return $this->resolvedIdentity; } $identity = $this->getStorage()->read(); if (is_int($identity) || is_scalar($identity)) { $identity = $this->getMapper()->findById($identity); } if ($identity) { $this->resolvedIdentity = $identity; } else { $this->resolvedIdentity = null; } return $this->resolvedIdentity; }
php
public function read() { if (null !== $this->resolvedIdentity) { return $this->resolvedIdentity; } $identity = $this->getStorage()->read(); if (is_int($identity) || is_scalar($identity)) { $identity = $this->getMapper()->findById($identity); } if ($identity) { $this->resolvedIdentity = $identity; } else { $this->resolvedIdentity = null; } return $this->resolvedIdentity; }
[ "public", "function", "read", "(", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "resolvedIdentity", ")", "{", "return", "$", "this", "->", "resolvedIdentity", ";", "}", "$", "identity", "=", "$", "this", "->", "getStorage", "(", ")", "->", ...
Returns the contents of storage Behavior is undefined when storage is empty. @throws \Zend\Authentication\Exception\InvalidArgumentException If reading contents from storage is impossible @return mixed
[ "Returns", "the", "contents", "of", "storage" ]
03c8d818807e5edf9cdc723a5460d6ed8ce9c550
https://github.com/ZF-Commons/ZfcUser/blob/03c8d818807e5edf9cdc723a5460d6ed8ce9c550/src/ZfcUser/Authentication/Storage/Db.php#L62-L81
train
ZF-Commons/ZfcUser
src/ZfcUser/Authentication/Adapter/AdapterChain.php
AdapterChain.getEvent
public function getEvent() { if (null === $this->event) { $this->setEvent(new AdapterChainEvent); $this->event->setTarget($this); } return $this->event; }
php
public function getEvent() { if (null === $this->event) { $this->setEvent(new AdapterChainEvent); $this->event->setTarget($this); } return $this->event; }
[ "public", "function", "getEvent", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "event", ")", "{", "$", "this", "->", "setEvent", "(", "new", "AdapterChainEvent", ")", ";", "$", "this", "->", "event", "->", "setTarget", "(", "$", "this"...
Get the auth event @return AdapterChainEvent
[ "Get", "the", "auth", "event" ]
03c8d818807e5edf9cdc723a5460d6ed8ce9c550
https://github.com/ZF-Commons/ZfcUser/blob/03c8d818807e5edf9cdc723a5460d6ed8ce9c550/src/ZfcUser/Authentication/Adapter/AdapterChain.php#L127-L135
train
ZF-Commons/ZfcUser
src/ZfcUser/Controller/UserController.php
UserController.changepasswordAction
public function changepasswordAction() { // if the user isn't logged in, we can't change password if (!$this->zfcUserAuthentication()->hasIdentity()) { // redirect to the login redirect route return $this->redirect()->toRoute($this->getOptions()->getLoginRedirectRoute()); } $form = $this->getChangePasswordForm(); $prg = $this->prg(static::ROUTE_CHANGEPASSWD); $fm = $this->flashMessenger()->setNamespace('change-password')->getMessages(); if (isset($fm[0])) { $status = $fm[0]; } else { $status = null; } if ($prg instanceof Response) { return $prg; } elseif ($prg === false) { return array( 'status' => $status, 'changePasswordForm' => $form, ); } $form->setData($prg); if (!$form->isValid()) { return array( 'status' => false, 'changePasswordForm' => $form, ); } if (!$this->getUserService()->changePassword($form->getData())) { return array( 'status' => false, 'changePasswordForm' => $form, ); } $this->flashMessenger()->setNamespace('change-password')->addMessage(true); return $this->redirect()->toRoute(static::ROUTE_CHANGEPASSWD); }
php
public function changepasswordAction() { // if the user isn't logged in, we can't change password if (!$this->zfcUserAuthentication()->hasIdentity()) { // redirect to the login redirect route return $this->redirect()->toRoute($this->getOptions()->getLoginRedirectRoute()); } $form = $this->getChangePasswordForm(); $prg = $this->prg(static::ROUTE_CHANGEPASSWD); $fm = $this->flashMessenger()->setNamespace('change-password')->getMessages(); if (isset($fm[0])) { $status = $fm[0]; } else { $status = null; } if ($prg instanceof Response) { return $prg; } elseif ($prg === false) { return array( 'status' => $status, 'changePasswordForm' => $form, ); } $form->setData($prg); if (!$form->isValid()) { return array( 'status' => false, 'changePasswordForm' => $form, ); } if (!$this->getUserService()->changePassword($form->getData())) { return array( 'status' => false, 'changePasswordForm' => $form, ); } $this->flashMessenger()->setNamespace('change-password')->addMessage(true); return $this->redirect()->toRoute(static::ROUTE_CHANGEPASSWD); }
[ "public", "function", "changepasswordAction", "(", ")", "{", "// if the user isn't logged in, we can't change password", "if", "(", "!", "$", "this", "->", "zfcUserAuthentication", "(", ")", "->", "hasIdentity", "(", ")", ")", "{", "// redirect to the login redirect route...
Change the users password
[ "Change", "the", "users", "password" ]
03c8d818807e5edf9cdc723a5460d6ed8ce9c550
https://github.com/ZF-Commons/ZfcUser/blob/03c8d818807e5edf9cdc723a5460d6ed8ce9c550/src/ZfcUser/Controller/UserController.php#L251-L296
train
ZF-Commons/ZfcUser
src/ZfcUser/Service/User.php
User.changePassword
public function changePassword(array $data) { $currentUser = $this->getAuthService()->getIdentity(); $oldPass = $data['credential']; $newPass = $data['newCredential']; $bcrypt = new Bcrypt; $bcrypt->setCost($this->getOptions()->getPasswordCost()); if (!$bcrypt->verify($oldPass, $currentUser->getPassword())) { return false; } $pass = $bcrypt->create($newPass); $currentUser->setPassword($pass); $this->getEventManager()->trigger(__FUNCTION__, $this, array('user' => $currentUser, 'data' => $data)); $this->getUserMapper()->update($currentUser); $this->getEventManager()->trigger(__FUNCTION__.'.post', $this, array('user' => $currentUser, 'data' => $data)); return true; }
php
public function changePassword(array $data) { $currentUser = $this->getAuthService()->getIdentity(); $oldPass = $data['credential']; $newPass = $data['newCredential']; $bcrypt = new Bcrypt; $bcrypt->setCost($this->getOptions()->getPasswordCost()); if (!$bcrypt->verify($oldPass, $currentUser->getPassword())) { return false; } $pass = $bcrypt->create($newPass); $currentUser->setPassword($pass); $this->getEventManager()->trigger(__FUNCTION__, $this, array('user' => $currentUser, 'data' => $data)); $this->getUserMapper()->update($currentUser); $this->getEventManager()->trigger(__FUNCTION__.'.post', $this, array('user' => $currentUser, 'data' => $data)); return true; }
[ "public", "function", "changePassword", "(", "array", "$", "data", ")", "{", "$", "currentUser", "=", "$", "this", "->", "getAuthService", "(", ")", "->", "getIdentity", "(", ")", ";", "$", "oldPass", "=", "$", "data", "[", "'credential'", "]", ";", "$...
change the current users password @param array $data @return boolean
[ "change", "the", "current", "users", "password" ]
03c8d818807e5edf9cdc723a5460d6ed8ce9c550
https://github.com/ZF-Commons/ZfcUser/blob/03c8d818807e5edf9cdc723a5460d6ed8ce9c550/src/ZfcUser/Service/User.php#L107-L129
train
ZF-Commons/ZfcUser
src/ZfcUser/Service/User.php
User.getOptions
public function getOptions() { if (!$this->options instanceof UserServiceOptionsInterface) { $this->setOptions($this->getServiceManager()->get('zfcuser_module_options')); } return $this->options; }
php
public function getOptions() { if (!$this->options instanceof UserServiceOptionsInterface) { $this->setOptions($this->getServiceManager()->get('zfcuser_module_options')); } return $this->options; }
[ "public", "function", "getOptions", "(", ")", "{", "if", "(", "!", "$", "this", "->", "options", "instanceof", "UserServiceOptionsInterface", ")", "{", "$", "this", "->", "setOptions", "(", "$", "this", "->", "getServiceManager", "(", ")", "->", "get", "("...
get service options @return UserServiceOptionsInterface
[ "get", "service", "options" ]
03c8d818807e5edf9cdc723a5460d6ed8ce9c550
https://github.com/ZF-Commons/ZfcUser/blob/03c8d818807e5edf9cdc723a5460d6ed8ce9c550/src/ZfcUser/Service/User.php#L248-L254
train
ZF-Commons/ZfcUser
src/ZfcUser/Service/User.php
User.getFormHydrator
public function getFormHydrator() { if (!$this->formHydrator instanceof Hydrator\HydratorInterface) { $this->setFormHydrator($this->getServiceManager()->get('zfcuser_register_form_hydrator')); } return $this->formHydrator; }
php
public function getFormHydrator() { if (!$this->formHydrator instanceof Hydrator\HydratorInterface) { $this->setFormHydrator($this->getServiceManager()->get('zfcuser_register_form_hydrator')); } return $this->formHydrator; }
[ "public", "function", "getFormHydrator", "(", ")", "{", "if", "(", "!", "$", "this", "->", "formHydrator", "instanceof", "Hydrator", "\\", "HydratorInterface", ")", "{", "$", "this", "->", "setFormHydrator", "(", "$", "this", "->", "getServiceManager", "(", ...
Return the Form Hydrator @return \Zend\Hydrator\ClassMethods
[ "Return", "the", "Form", "Hydrator" ]
03c8d818807e5edf9cdc723a5460d6ed8ce9c550
https://github.com/ZF-Commons/ZfcUser/blob/03c8d818807e5edf9cdc723a5460d6ed8ce9c550/src/ZfcUser/Service/User.php#L293-L300
train
ZF-Commons/ZfcUser
src/ZfcUser/Mapper/AbstractDbMapper.php
AbstractDbMapper.initialize
protected function initialize() { if ($this->isInitialized) { return; } if (!$this->dbAdapter instanceof Adapter) { throw new \Exception('No db adapter present'); } if (!$this->hydrator instanceof HydratorInterface) { $this->hydrator = new ClassMethods; } if (!is_object($this->entityPrototype)) { throw new \Exception('No entity prototype set'); } $this->isInitialized = true; }
php
protected function initialize() { if ($this->isInitialized) { return; } if (!$this->dbAdapter instanceof Adapter) { throw new \Exception('No db adapter present'); } if (!$this->hydrator instanceof HydratorInterface) { $this->hydrator = new ClassMethods; } if (!is_object($this->entityPrototype)) { throw new \Exception('No entity prototype set'); } $this->isInitialized = true; }
[ "protected", "function", "initialize", "(", ")", "{", "if", "(", "$", "this", "->", "isInitialized", ")", "{", "return", ";", "}", "if", "(", "!", "$", "this", "->", "dbAdapter", "instanceof", "Adapter", ")", "{", "throw", "new", "\\", "Exception", "("...
Performs some basic initialization setup and checks before running a query @throws \Exception @return null
[ "Performs", "some", "basic", "initialization", "setup", "and", "checks", "before", "running", "a", "query" ]
03c8d818807e5edf9cdc723a5460d6ed8ce9c550
https://github.com/ZF-Commons/ZfcUser/blob/03c8d818807e5edf9cdc723a5460d6ed8ce9c550/src/ZfcUser/Mapper/AbstractDbMapper.php#L73-L89
train
AlexaCRM/php-crm-toolkit
src/SoapRequestsGenerator.php
SoapRequestsGenerator.generateCreateRequest
public static function generateCreateRequest( Entity $entity ) { /* Generate the CreateRequest message */ $createRequestDOM = new DOMDocument(); $createNode = $createRequestDOM->appendChild( $createRequestDOM->createElementNS( 'http://schemas.microsoft.com/xrm/2011/Contracts/Services', 'Create' ) ); $createNode->appendChild( $createRequestDOM->importNode( $entity->getEntityDOM(), true ) ); /* Return the DOMNode */ return $createNode; }
php
public static function generateCreateRequest( Entity $entity ) { /* Generate the CreateRequest message */ $createRequestDOM = new DOMDocument(); $createNode = $createRequestDOM->appendChild( $createRequestDOM->createElementNS( 'http://schemas.microsoft.com/xrm/2011/Contracts/Services', 'Create' ) ); $createNode->appendChild( $createRequestDOM->importNode( $entity->getEntityDOM(), true ) ); /* Return the DOMNode */ return $createNode; }
[ "public", "static", "function", "generateCreateRequest", "(", "Entity", "$", "entity", ")", "{", "/* Generate the CreateRequest message */", "$", "createRequestDOM", "=", "new", "DOMDocument", "(", ")", ";", "$", "createNode", "=", "$", "createRequestDOM", "->", "ap...
Generate a Create Request @param Entity $entity @return DOMNode
[ "Generate", "a", "Create", "Request" ]
29995814d03987302c1690992f5a6e1221310d24
https://github.com/AlexaCRM/php-crm-toolkit/blob/29995814d03987302c1690992f5a6e1221310d24/src/SoapRequestsGenerator.php#L42-L51
train
AlexaCRM/php-crm-toolkit
src/SoapRequestsGenerator.php
SoapRequestsGenerator.generateDeleteRequest
public static function generateDeleteRequest( Entity $entity ) { /* Generate the DeleteRequest message */ $deleteRequestDOM = new DOMDocument(); $deleteNode = $deleteRequestDOM->appendChild( $deleteRequestDOM->createElementNS( 'http://schemas.microsoft.com/xrm/2011/Contracts/Services', 'Delete' ) ); $deleteNode->appendChild( $deleteRequestDOM->createElement( 'entityName', $entity->logicalName ) ); $deleteNode->appendChild( $deleteRequestDOM->createElement( 'id', $entity->ID ) ); /* Return the DOMNode */ return $deleteNode; }
php
public static function generateDeleteRequest( Entity $entity ) { /* Generate the DeleteRequest message */ $deleteRequestDOM = new DOMDocument(); $deleteNode = $deleteRequestDOM->appendChild( $deleteRequestDOM->createElementNS( 'http://schemas.microsoft.com/xrm/2011/Contracts/Services', 'Delete' ) ); $deleteNode->appendChild( $deleteRequestDOM->createElement( 'entityName', $entity->logicalName ) ); $deleteNode->appendChild( $deleteRequestDOM->createElement( 'id', $entity->ID ) ); /* Return the DOMNode */ return $deleteNode; }
[ "public", "static", "function", "generateDeleteRequest", "(", "Entity", "$", "entity", ")", "{", "/* Generate the DeleteRequest message */", "$", "deleteRequestDOM", "=", "new", "DOMDocument", "(", ")", ";", "$", "deleteNode", "=", "$", "deleteRequestDOM", "->", "ap...
Generate a Delete Request @param Entity $entity the Entity to delete @ignore
[ "Generate", "a", "Delete", "Request" ]
29995814d03987302c1690992f5a6e1221310d24
https://github.com/AlexaCRM/php-crm-toolkit/blob/29995814d03987302c1690992f5a6e1221310d24/src/SoapRequestsGenerator.php#L261-L271
train
AlexaCRM/php-crm-toolkit
src/SoapRequestsGenerator.php
SoapRequestsGenerator.generateRetrieveRequest
public static function generateRetrieveRequest( $entityType, $entityId, $columnSet ) { /* Generate the RetrieveRequest message */ $retrieveRequestDOM = new DOMDocument(); $retrieveNode = $retrieveRequestDOM->appendChild( $retrieveRequestDOM->createElementNS( 'http://schemas.microsoft.com/xrm/2011/Contracts/Services', 'Retrieve' ) ); $retrieveNode->appendChild( $retrieveRequestDOM->createElement( 'entityName', $entityType ) ); $retrieveNode->appendChild( $retrieveRequestDOM->createElement( 'id', $entityId ) ); $columnSetNode = $retrieveNode->appendChild( $retrieveRequestDOM->createElement( 'columnSet' ) ); $columnSetNode->setAttributeNS( 'http://www.w3.org/2000/xmlns/', 'xmlns:b', 'http://schemas.microsoft.com/xrm/2011/Contracts' ); $columnSetNode->setAttributeNS( 'http://www.w3.org/2000/xmlns/', 'xmlns:i', 'http://www.w3.org/2001/XMLSchema-instance' ); /* Add the columns requested, if specified */ if ( $columnSet != null && count( $columnSet ) > 0 ) { $columnSetNode->appendChild( $retrieveRequestDOM->createElement( 'b:AllColumns', 'false' ) ); $columnsNode = $columnSetNode->appendChild( $retrieveRequestDOM->createElement( 'b:Columns' ) ); $columnsNode->setAttributeNS( 'http://www.w3.org/2000/xmlns/', 'xmlns:c', 'http://schemas.microsoft.com/2003/10/Serialization/Arrays' ); foreach ( $columnSet as $columnName ) { $columnsNode->appendChild( $retrieveRequestDOM->createElement( 'c:string', strtolower( $columnName ) ) ); } } else { /* No columns specified, request all of them */ $columnSetNode->appendChild( $retrieveRequestDOM->createElement( 'b:AllColumns', 'true' ) ); } /* Return the DOMNode */ return $retrieveNode; }
php
public static function generateRetrieveRequest( $entityType, $entityId, $columnSet ) { /* Generate the RetrieveRequest message */ $retrieveRequestDOM = new DOMDocument(); $retrieveNode = $retrieveRequestDOM->appendChild( $retrieveRequestDOM->createElementNS( 'http://schemas.microsoft.com/xrm/2011/Contracts/Services', 'Retrieve' ) ); $retrieveNode->appendChild( $retrieveRequestDOM->createElement( 'entityName', $entityType ) ); $retrieveNode->appendChild( $retrieveRequestDOM->createElement( 'id', $entityId ) ); $columnSetNode = $retrieveNode->appendChild( $retrieveRequestDOM->createElement( 'columnSet' ) ); $columnSetNode->setAttributeNS( 'http://www.w3.org/2000/xmlns/', 'xmlns:b', 'http://schemas.microsoft.com/xrm/2011/Contracts' ); $columnSetNode->setAttributeNS( 'http://www.w3.org/2000/xmlns/', 'xmlns:i', 'http://www.w3.org/2001/XMLSchema-instance' ); /* Add the columns requested, if specified */ if ( $columnSet != null && count( $columnSet ) > 0 ) { $columnSetNode->appendChild( $retrieveRequestDOM->createElement( 'b:AllColumns', 'false' ) ); $columnsNode = $columnSetNode->appendChild( $retrieveRequestDOM->createElement( 'b:Columns' ) ); $columnsNode->setAttributeNS( 'http://www.w3.org/2000/xmlns/', 'xmlns:c', 'http://schemas.microsoft.com/2003/10/Serialization/Arrays' ); foreach ( $columnSet as $columnName ) { $columnsNode->appendChild( $retrieveRequestDOM->createElement( 'c:string', strtolower( $columnName ) ) ); } } else { /* No columns specified, request all of them */ $columnSetNode->appendChild( $retrieveRequestDOM->createElement( 'b:AllColumns', 'true' ) ); } /* Return the DOMNode */ return $retrieveNode; }
[ "public", "static", "function", "generateRetrieveRequest", "(", "$", "entityType", ",", "$", "entityId", ",", "$", "columnSet", ")", "{", "/* Generate the RetrieveRequest message */", "$", "retrieveRequestDOM", "=", "new", "DOMDocument", "(", ")", ";", "$", "retriev...
Generate a Retrieve Request @ignore
[ "Generate", "a", "Retrieve", "Request" ]
29995814d03987302c1690992f5a6e1221310d24
https://github.com/AlexaCRM/php-crm-toolkit/blob/29995814d03987302c1690992f5a6e1221310d24/src/SoapRequestsGenerator.php#L320-L345
train
AlexaCRM/php-crm-toolkit
src/SoapRequestsGenerator.php
SoapRequestsGenerator.generateRetrieveOrganizationRequest
public static function generateRetrieveOrganizationRequest() { $retrieveOrganizationRequestDOM = new DOMDocument(); $executeNode = $retrieveOrganizationRequestDOM->appendChild( $retrieveOrganizationRequestDOM->createElementNS( 'http://schemas.microsoft.com/xrm/2011/Contracts/Discovery', 'Execute' ) ); $requestNode = $executeNode->appendChild( $retrieveOrganizationRequestDOM->createElement( 'request' ) ); $requestNode->setAttributeNS( 'http://www.w3.org/2001/XMLSchema-instance', 'i:type', 'RetrieveOrganizationsRequest' ); $requestNode->appendChild( $retrieveOrganizationRequestDOM->createElement( 'AccessType', 'Default' ) ); $requestNode->appendChild( $retrieveOrganizationRequestDOM->createElement( 'Release', 'Current' ) ); return $executeNode; }
php
public static function generateRetrieveOrganizationRequest() { $retrieveOrganizationRequestDOM = new DOMDocument(); $executeNode = $retrieveOrganizationRequestDOM->appendChild( $retrieveOrganizationRequestDOM->createElementNS( 'http://schemas.microsoft.com/xrm/2011/Contracts/Discovery', 'Execute' ) ); $requestNode = $executeNode->appendChild( $retrieveOrganizationRequestDOM->createElement( 'request' ) ); $requestNode->setAttributeNS( 'http://www.w3.org/2001/XMLSchema-instance', 'i:type', 'RetrieveOrganizationsRequest' ); $requestNode->appendChild( $retrieveOrganizationRequestDOM->createElement( 'AccessType', 'Default' ) ); $requestNode->appendChild( $retrieveOrganizationRequestDOM->createElement( 'Release', 'Current' ) ); return $executeNode; }
[ "public", "static", "function", "generateRetrieveOrganizationRequest", "(", ")", "{", "$", "retrieveOrganizationRequestDOM", "=", "new", "DOMDocument", "(", ")", ";", "$", "executeNode", "=", "$", "retrieveOrganizationRequestDOM", "->", "appendChild", "(", "$", "retri...
Utility function to generate the XML for a Retrieve Organization request This XML can be sent as a SOAP message to the Discovery Service to determine all Organizations available on that service. @return DOMNode containing the XML for a RetrieveOrganizationRequest message @ignore
[ "Utility", "function", "to", "generate", "the", "XML", "for", "a", "Retrieve", "Organization", "request", "This", "XML", "can", "be", "sent", "as", "a", "SOAP", "message", "to", "the", "Discovery", "Service", "to", "determine", "all", "Organizations", "availab...
29995814d03987302c1690992f5a6e1221310d24
https://github.com/AlexaCRM/php-crm-toolkit/blob/29995814d03987302c1690992f5a6e1221310d24/src/SoapRequestsGenerator.php#L426-L435
train
AlexaCRM/php-crm-toolkit
src/SoapRequestsGenerator.php
SoapRequestsGenerator.generateRetrieveMultipleRequest
public static function generateRetrieveMultipleRequest( $queryXML, $pagingCookie = null, $limitCount = null, $pageNumber = null ) { /* Turn the queryXML into a DOMDocument so we can manipulate it */ $queryDOM = new DOMDocument(); $queryDOM->loadXML( $queryXML ); $newPage = 1; if ( $queryDOM->documentElement->hasAttribute( 'page' ) ) { $newPage = (int)$queryDOM->documentElement->getAttribute( 'page' ); } if ( $pagingCookie !== null ) { $newPage = Client::getPageNo( $pagingCookie ) + 1; $queryDOM->documentElement->setAttribute( 'paging-cookie', $pagingCookie ); } elseif ( $pageNumber !== null ) { $newPage = $pageNumber; } /* Modify the query that we send: Add the Page number */ $queryDOM->documentElement->setAttribute( 'page', $newPage ); /* Find the current limit, if there is one */ $currentLimit = Client::getMaximumRecords() + 1; if ( $queryDOM->documentElement->hasAttribute( 'count' ) ) { $currentLimit = $queryDOM->documentElement->getAttribute( 'count' ); } /* Determine the preferred limit (passed by argument, or 5000 if not set) */ $preferredLimit = ( $limitCount == null ) ? $currentLimit : $limitCount; if ( $preferredLimit > Client::getMaximumRecords() ) { $preferredLimit = Client::getMaximumRecords(); } /* If the current limit is not set, or is greater than the preferred limit, override it */ if ( $currentLimit > $preferredLimit ) { /* Modify the query that we send: Change the Count */ $queryDOM->documentElement->setAttribute( 'count', $preferredLimit ); /* Update the Query XML with the new structure */ } $queryXML = $queryDOM->saveXML( $queryDOM->documentElement ); /* Generate the RetrieveMultipleRequest message */ $retrieveMultipleRequestDOM = new DOMDocument(); $retrieveMultipleNode = $retrieveMultipleRequestDOM->appendChild( $retrieveMultipleRequestDOM->createElementNS( 'http://schemas.microsoft.com/xrm/2011/Contracts/Services', 'RetrieveMultiple' ) ); $queryNode = $retrieveMultipleNode->appendChild( $retrieveMultipleRequestDOM->createElement( 'query' ) ); $queryNode->setAttributeNS( 'http://www.w3.org/2001/XMLSchema-instance', 'i:type', 'b:FetchExpression' ); $queryNode->setAttributeNS( 'http://www.w3.org/2000/xmlns/', 'xmlns:b', 'http://schemas.microsoft.com/xrm/2011/Contracts' ); $queryNode->appendChild( $retrieveMultipleRequestDOM->createElement( 'b:Query', trim( htmlentities( $queryXML ) ) ) ); /* Return the DOMNode */ return $retrieveMultipleNode; }
php
public static function generateRetrieveMultipleRequest( $queryXML, $pagingCookie = null, $limitCount = null, $pageNumber = null ) { /* Turn the queryXML into a DOMDocument so we can manipulate it */ $queryDOM = new DOMDocument(); $queryDOM->loadXML( $queryXML ); $newPage = 1; if ( $queryDOM->documentElement->hasAttribute( 'page' ) ) { $newPage = (int)$queryDOM->documentElement->getAttribute( 'page' ); } if ( $pagingCookie !== null ) { $newPage = Client::getPageNo( $pagingCookie ) + 1; $queryDOM->documentElement->setAttribute( 'paging-cookie', $pagingCookie ); } elseif ( $pageNumber !== null ) { $newPage = $pageNumber; } /* Modify the query that we send: Add the Page number */ $queryDOM->documentElement->setAttribute( 'page', $newPage ); /* Find the current limit, if there is one */ $currentLimit = Client::getMaximumRecords() + 1; if ( $queryDOM->documentElement->hasAttribute( 'count' ) ) { $currentLimit = $queryDOM->documentElement->getAttribute( 'count' ); } /* Determine the preferred limit (passed by argument, or 5000 if not set) */ $preferredLimit = ( $limitCount == null ) ? $currentLimit : $limitCount; if ( $preferredLimit > Client::getMaximumRecords() ) { $preferredLimit = Client::getMaximumRecords(); } /* If the current limit is not set, or is greater than the preferred limit, override it */ if ( $currentLimit > $preferredLimit ) { /* Modify the query that we send: Change the Count */ $queryDOM->documentElement->setAttribute( 'count', $preferredLimit ); /* Update the Query XML with the new structure */ } $queryXML = $queryDOM->saveXML( $queryDOM->documentElement ); /* Generate the RetrieveMultipleRequest message */ $retrieveMultipleRequestDOM = new DOMDocument(); $retrieveMultipleNode = $retrieveMultipleRequestDOM->appendChild( $retrieveMultipleRequestDOM->createElementNS( 'http://schemas.microsoft.com/xrm/2011/Contracts/Services', 'RetrieveMultiple' ) ); $queryNode = $retrieveMultipleNode->appendChild( $retrieveMultipleRequestDOM->createElement( 'query' ) ); $queryNode->setAttributeNS( 'http://www.w3.org/2001/XMLSchema-instance', 'i:type', 'b:FetchExpression' ); $queryNode->setAttributeNS( 'http://www.w3.org/2000/xmlns/', 'xmlns:b', 'http://schemas.microsoft.com/xrm/2011/Contracts' ); $queryNode->appendChild( $retrieveMultipleRequestDOM->createElement( 'b:Query', trim( htmlentities( $queryXML ) ) ) ); /* Return the DOMNode */ return $retrieveMultipleNode; }
[ "public", "static", "function", "generateRetrieveMultipleRequest", "(", "$", "queryXML", ",", "$", "pagingCookie", "=", "null", ",", "$", "limitCount", "=", "null", ",", "$", "pageNumber", "=", "null", ")", "{", "/* Turn the queryXML into a DOMDocument so we can manip...
Generate a Retrieve Multiple Request @ignore
[ "Generate", "a", "Retrieve", "Multiple", "Request" ]
29995814d03987302c1690992f5a6e1221310d24
https://github.com/AlexaCRM/php-crm-toolkit/blob/29995814d03987302c1690992f5a6e1221310d24/src/SoapRequestsGenerator.php#L442-L494
train
AlexaCRM/php-crm-toolkit
src/Entity/EntityReference.php
EntityReference.equals
public function equals( $reference ) { if ( !( $reference instanceof EntityReference ) ) { return false; } if ( strcasecmp( $this->entityLogicalName, $reference->entityLogicalName ) !== 0 ) { return false; } if ( $this->getID() !== $reference->getID() ) { return false; } return true; }
php
public function equals( $reference ) { if ( !( $reference instanceof EntityReference ) ) { return false; } if ( strcasecmp( $this->entityLogicalName, $reference->entityLogicalName ) !== 0 ) { return false; } if ( $this->getID() !== $reference->getID() ) { return false; } return true; }
[ "public", "function", "equals", "(", "$", "reference", ")", "{", "if", "(", "!", "(", "$", "reference", "instanceof", "EntityReference", ")", ")", "{", "return", "false", ";", "}", "if", "(", "strcasecmp", "(", "$", "this", "->", "entityLogicalName", ","...
Determines whether two entity references are equal. @param mixed $reference @return bool
[ "Determines", "whether", "two", "entity", "references", "are", "equal", "." ]
29995814d03987302c1690992f5a6e1221310d24
https://github.com/AlexaCRM/php-crm-toolkit/blob/29995814d03987302c1690992f5a6e1221310d24/src/Entity/EntityReference.php#L167-L181
train
AlexaCRM/php-crm-toolkit
src/Entity/MetadataCollection.php
MetadataCollection.retrieveMetadata
private function retrieveMetadata( $entityLogicalName, $force = false ) { // check memory if ( array_key_exists( $entityLogicalName, $this->cachedEntityDefinitions ) ) { return $this->cachedEntityDefinitions[ $entityLogicalName ]; } // check storage if ( $this->storage->exists( $entityLogicalName ) ) { $entityMetadata = $this->storage->get( $entityLogicalName ); $this->cachedEntityDefinitions[ $entityLogicalName ] = $entityMetadata; return $entityMetadata; } /** * Fetch metadata from CRM and store it in memory and storage (if available). * * If no storage is available, data will be fetched from the CRM on every SDK execution * (web request, cli run). */ $client = $this->client; $entityObject = $client->retrieveEntity( $entityLogicalName ); $metadata = new Metadata( $entityLogicalName, $entityObject ); $this->cachedEntityDefinitions[ $entityLogicalName ] = $metadata; $this->storage->set( $entityLogicalName, $metadata ); return $metadata; }
php
private function retrieveMetadata( $entityLogicalName, $force = false ) { // check memory if ( array_key_exists( $entityLogicalName, $this->cachedEntityDefinitions ) ) { return $this->cachedEntityDefinitions[ $entityLogicalName ]; } // check storage if ( $this->storage->exists( $entityLogicalName ) ) { $entityMetadata = $this->storage->get( $entityLogicalName ); $this->cachedEntityDefinitions[ $entityLogicalName ] = $entityMetadata; return $entityMetadata; } /** * Fetch metadata from CRM and store it in memory and storage (if available). * * If no storage is available, data will be fetched from the CRM on every SDK execution * (web request, cli run). */ $client = $this->client; $entityObject = $client->retrieveEntity( $entityLogicalName ); $metadata = new Metadata( $entityLogicalName, $entityObject ); $this->cachedEntityDefinitions[ $entityLogicalName ] = $metadata; $this->storage->set( $entityLogicalName, $metadata ); return $metadata; }
[ "private", "function", "retrieveMetadata", "(", "$", "entityLogicalName", ",", "$", "force", "=", "false", ")", "{", "// check memory", "if", "(", "array_key_exists", "(", "$", "entityLogicalName", ",", "$", "this", "->", "cachedEntityDefinitions", ")", ")", "{"...
Retrieve Entity Metadata via CRM @param string $entityLogicalName @param bool $force Bypass cache if true @return Metadata
[ "Retrieve", "Entity", "Metadata", "via", "CRM" ]
29995814d03987302c1690992f5a6e1221310d24
https://github.com/AlexaCRM/php-crm-toolkit/blob/29995814d03987302c1690992f5a6e1221310d24/src/Entity/MetadataCollection.php#L171-L199
train
AlexaCRM/php-crm-toolkit
src/Auth/Authentication.php
Authentication.getToken
public function getToken( $service ) { if ( $this->isTokenLoaded( $service ) && !$this->isTokenExpired( $service ) ) { return $this->tokens[$service]; } $tokenCacheKey = $this->getTokenCacheKey( $service ); $cachedToken = $this->client->cache->get( $tokenCacheKey ); if ( $cachedToken instanceof SecurityToken && !$cachedToken->hasExpired() ) { $this->tokens[$service] = $cachedToken; // save in memory return $cachedToken; } $this->tokens[$service] = $newToken = $this->retrieveToken( $service ); $this->client->cache->set( $tokenCacheKey, $newToken, floor( $newToken->expiryTime - time() - 60 ) ); return $newToken; }
php
public function getToken( $service ) { if ( $this->isTokenLoaded( $service ) && !$this->isTokenExpired( $service ) ) { return $this->tokens[$service]; } $tokenCacheKey = $this->getTokenCacheKey( $service ); $cachedToken = $this->client->cache->get( $tokenCacheKey ); if ( $cachedToken instanceof SecurityToken && !$cachedToken->hasExpired() ) { $this->tokens[$service] = $cachedToken; // save in memory return $cachedToken; } $this->tokens[$service] = $newToken = $this->retrieveToken( $service ); $this->client->cache->set( $tokenCacheKey, $newToken, floor( $newToken->expiryTime - time() - 60 ) ); return $newToken; }
[ "public", "function", "getToken", "(", "$", "service", ")", "{", "if", "(", "$", "this", "->", "isTokenLoaded", "(", "$", "service", ")", "&&", "!", "$", "this", "->", "isTokenExpired", "(", "$", "service", ")", ")", "{", "return", "$", "this", "->",...
Retrieves a security token for the specified service. @param string $service Can be 'organization', 'discovery' @return SecurityToken
[ "Retrieves", "a", "security", "token", "for", "the", "specified", "service", "." ]
29995814d03987302c1690992f5a6e1221310d24
https://github.com/AlexaCRM/php-crm-toolkit/blob/29995814d03987302c1690992f5a6e1221310d24/src/Auth/Authentication.php#L89-L107
train
AlexaCRM/php-crm-toolkit
src/Auth/Authentication.php
Authentication.isTokenExpired
protected function isTokenExpired( $service ) { if ( !$this->isTokenLoaded( $service ) ) { $this->tokens[$service] = $this->getToken( $service ); } return $this->tokens[$service]->hasExpired(); }
php
protected function isTokenExpired( $service ) { if ( !$this->isTokenLoaded( $service ) ) { $this->tokens[$service] = $this->getToken( $service ); } return $this->tokens[$service]->hasExpired(); }
[ "protected", "function", "isTokenExpired", "(", "$", "service", ")", "{", "if", "(", "!", "$", "this", "->", "isTokenLoaded", "(", "$", "service", ")", ")", "{", "$", "this", "->", "tokens", "[", "$", "service", "]", "=", "$", "this", "->", "getToken...
Tells whether the given service token has expired. @param string $service @return bool
[ "Tells", "whether", "the", "given", "service", "token", "has", "expired", "." ]
29995814d03987302c1690992f5a6e1221310d24
https://github.com/AlexaCRM/php-crm-toolkit/blob/29995814d03987302c1690992f5a6e1221310d24/src/Auth/Authentication.php#L155-L161
train
AlexaCRM/php-crm-toolkit
src/Auth/Authentication.php
Authentication.isTokenLoaded
protected function isTokenLoaded( $service ) { return ( array_key_exists( $service, $this->tokens ) && ( $this->tokens[$service] instanceof SecurityToken ) ); }
php
protected function isTokenLoaded( $service ) { return ( array_key_exists( $service, $this->tokens ) && ( $this->tokens[$service] instanceof SecurityToken ) ); }
[ "protected", "function", "isTokenLoaded", "(", "$", "service", ")", "{", "return", "(", "array_key_exists", "(", "$", "service", ",", "$", "this", "->", "tokens", ")", "&&", "(", "$", "this", "->", "tokens", "[", "$", "service", "]", "instanceof", "Secur...
Checks whether security token for given service is loaded into memory. @param string $service @return bool
[ "Checks", "whether", "security", "token", "for", "given", "service", "is", "loaded", "into", "memory", "." ]
29995814d03987302c1690992f5a6e1221310d24
https://github.com/AlexaCRM/php-crm-toolkit/blob/29995814d03987302c1690992f5a6e1221310d24/src/Auth/Authentication.php#L170-L172
train
AlexaCRM/php-crm-toolkit
src/Auth/Authentication.php
Authentication.invalidateToken
public function invalidateToken( $service ) { unset( $this->tokens[$service] ); $cacheKey = $this->getTokenCacheKey( $service ); $this->client->cache->delete( $cacheKey ); $this->client->logger->notice( 'Invalidated token for ' . ucfirst( $service ) . 'Service' ); }
php
public function invalidateToken( $service ) { unset( $this->tokens[$service] ); $cacheKey = $this->getTokenCacheKey( $service ); $this->client->cache->delete( $cacheKey ); $this->client->logger->notice( 'Invalidated token for ' . ucfirst( $service ) . 'Service' ); }
[ "public", "function", "invalidateToken", "(", "$", "service", ")", "{", "unset", "(", "$", "this", "->", "tokens", "[", "$", "service", "]", ")", ";", "$", "cacheKey", "=", "$", "this", "->", "getTokenCacheKey", "(", "$", "service", ")", ";", "$", "t...
Invalidates the token for a given service. @param string $service @return void
[ "Invalidates", "the", "token", "for", "a", "given", "service", "." ]
29995814d03987302c1690992f5a6e1221310d24
https://github.com/AlexaCRM/php-crm-toolkit/blob/29995814d03987302c1690992f5a6e1221310d24/src/Auth/Authentication.php#L192-L199
train
AlexaCRM/php-crm-toolkit
src/Auth/Authentication.php
Authentication.getTokenCredentials
protected function getTokenCredentials() { return [ 'server' => $this->settings->getServiceEndpoint( 'sts' ), 'endpoint' => $this->settings->getAuthenticationEndpoint(), 'username' => $this->settings->username, 'password' => $this->settings->password, ]; }
php
protected function getTokenCredentials() { return [ 'server' => $this->settings->getServiceEndpoint( 'sts' ), 'endpoint' => $this->settings->getAuthenticationEndpoint(), 'username' => $this->settings->username, 'password' => $this->settings->password, ]; }
[ "protected", "function", "getTokenCredentials", "(", ")", "{", "return", "[", "'server'", "=>", "$", "this", "->", "settings", "->", "getServiceEndpoint", "(", "'sts'", ")", ",", "'endpoint'", "=>", "$", "this", "->", "settings", "->", "getAuthenticationEndpoint...
Returns server, endpoint, username, password. @return array
[ "Returns", "server", "endpoint", "username", "password", "." ]
29995814d03987302c1690992f5a6e1221310d24
https://github.com/AlexaCRM/php-crm-toolkit/blob/29995814d03987302c1690992f5a6e1221310d24/src/Auth/Authentication.php#L206-L213
train
AlexaCRM/php-crm-toolkit
src/Settings.php
Settings.isFullSettings
public function isFullSettings() { return ( $this->discoveryUrl && $this->username && $this->password && $this->organizationUrl && $this->loginUrl && ( ( $this->authMode === 'OnlineFederation' ) ? $this->crmRegion : true ) ); }
php
public function isFullSettings() { return ( $this->discoveryUrl && $this->username && $this->password && $this->organizationUrl && $this->loginUrl && ( ( $this->authMode === 'OnlineFederation' ) ? $this->crmRegion : true ) ); }
[ "public", "function", "isFullSettings", "(", ")", "{", "return", "(", "$", "this", "->", "discoveryUrl", "&&", "$", "this", "->", "username", "&&", "$", "this", "->", "password", "&&", "$", "this", "->", "organizationUrl", "&&", "$", "this", "->", "login...
Check if all required settings are filled @return bool
[ "Check", "if", "all", "required", "settings", "are", "filled" ]
29995814d03987302c1690992f5a6e1221310d24
https://github.com/AlexaCRM/php-crm-toolkit/blob/29995814d03987302c1690992f5a6e1221310d24/src/Settings.php#L252-L255
train
AlexaCRM/php-crm-toolkit
src/Settings.php
Settings.getServiceEndpoint
public function getServiceEndpoint( $service ) { switch ( $service ) { case 'organization': return $this->organizationUrl; case 'discovery': return $this->discoveryUrl; case 'sts': case 'login': return $this->loginUrl; default: return $service; } }
php
public function getServiceEndpoint( $service ) { switch ( $service ) { case 'organization': return $this->organizationUrl; case 'discovery': return $this->discoveryUrl; case 'sts': case 'login': return $this->loginUrl; default: return $service; } }
[ "public", "function", "getServiceEndpoint", "(", "$", "service", ")", "{", "switch", "(", "$", "service", ")", "{", "case", "'organization'", ":", "return", "$", "this", "->", "organizationUrl", ";", "case", "'discovery'", ":", "return", "$", "this", "->", ...
Retrieves endpoint URI for the given service. @param string $service @return string
[ "Retrieves", "endpoint", "URI", "for", "the", "given", "service", "." ]
29995814d03987302c1690992f5a6e1221310d24
https://github.com/AlexaCRM/php-crm-toolkit/blob/29995814d03987302c1690992f5a6e1221310d24/src/Settings.php#L274-L286
train
AlexaCRM/php-crm-toolkit
src/Settings.php
Settings.getAuthenticationEndpoint
public function getAuthenticationEndpoint() { switch ( $this->authMode ) { case 'OnlineFederation': return $this->crmRegion; case 'Federation': return $this->organizationUrl; default: throw new \InvalidArgumentException( 'Unsupported authentication mode: ' . $this->authMode ); } }
php
public function getAuthenticationEndpoint() { switch ( $this->authMode ) { case 'OnlineFederation': return $this->crmRegion; case 'Federation': return $this->organizationUrl; default: throw new \InvalidArgumentException( 'Unsupported authentication mode: ' . $this->authMode ); } }
[ "public", "function", "getAuthenticationEndpoint", "(", ")", "{", "switch", "(", "$", "this", "->", "authMode", ")", "{", "case", "'OnlineFederation'", ":", "return", "$", "this", "->", "crmRegion", ";", "case", "'Federation'", ":", "return", "$", "this", "-...
Retrieves authentication endpoint for the STS. @return string
[ "Retrieves", "authentication", "endpoint", "for", "the", "STS", "." ]
29995814d03987302c1690992f5a6e1221310d24
https://github.com/AlexaCRM/php-crm-toolkit/blob/29995814d03987302c1690992f5a6e1221310d24/src/Settings.php#L293-L302
train
AlexaCRM/php-crm-toolkit
src/Settings.php
Settings.validateInput
private function validateInput( $settings ) { if ( !isset( $settings["serverUrl"] ) || !isset( $settings["username"] ) || !isset( $settings["password"] ) ) { throw new \InvalidArgumentException( 'Username, password or serverUrl is incorrect' ); } if ( !filter_var( $settings["serverUrl"], FILTER_VALIDATE_URL ) || strpos( $settings["serverUrl"], "." ) === false ) { throw new \InvalidArgumentException( 'Invalid serverUrl has been provided' ); } if ( !in_array( $settings['authMode'], [ 'OnlineFederation', 'Federation' ] ) ) { throw new \InvalidArgumentException( 'Provided authentication mode <' . $this->authMode . '> is not supported' ); } }
php
private function validateInput( $settings ) { if ( !isset( $settings["serverUrl"] ) || !isset( $settings["username"] ) || !isset( $settings["password"] ) ) { throw new \InvalidArgumentException( 'Username, password or serverUrl is incorrect' ); } if ( !filter_var( $settings["serverUrl"], FILTER_VALIDATE_URL ) || strpos( $settings["serverUrl"], "." ) === false ) { throw new \InvalidArgumentException( 'Invalid serverUrl has been provided' ); } if ( !in_array( $settings['authMode'], [ 'OnlineFederation', 'Federation' ] ) ) { throw new \InvalidArgumentException( 'Provided authentication mode <' . $this->authMode . '> is not supported' ); } }
[ "private", "function", "validateInput", "(", "$", "settings", ")", "{", "if", "(", "!", "isset", "(", "$", "settings", "[", "\"serverUrl\"", "]", ")", "||", "!", "isset", "(", "$", "settings", "[", "\"username\"", "]", ")", "||", "!", "isset", "(", "...
Validates settings input. @param array $settings
[ "Validates", "settings", "input", "." ]
29995814d03987302c1690992f5a6e1221310d24
https://github.com/AlexaCRM/php-crm-toolkit/blob/29995814d03987302c1690992f5a6e1221310d24/src/Settings.php#L322-L339
train
AlexaCRM/php-crm-toolkit
src/Settings.php
Settings.validateUrl
private function validateUrl( $urlParts ) { if ( !is_array( $urlParts ) ) { throw new \InvalidArgumentException( 'Invalid serverUrl has been provided' ); } if ( !isset( $urlParts["scheme"] ) ) { throw new \InvalidArgumentException( 'serverUrl has been provided without a valid scheme (http:// or https://)' ); } if ( !isset( $urlParts["host"] ) ) { throw new \InvalidArgumentException( 'Invalid serverUrl has been provided' ); } }
php
private function validateUrl( $urlParts ) { if ( !is_array( $urlParts ) ) { throw new \InvalidArgumentException( 'Invalid serverUrl has been provided' ); } if ( !isset( $urlParts["scheme"] ) ) { throw new \InvalidArgumentException( 'serverUrl has been provided without a valid scheme (http:// or https://)' ); } if ( !isset( $urlParts["host"] ) ) { throw new \InvalidArgumentException( 'Invalid serverUrl has been provided' ); } }
[ "private", "function", "validateUrl", "(", "$", "urlParts", ")", "{", "if", "(", "!", "is_array", "(", "$", "urlParts", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Invalid serverUrl has been provided'", ")", ";", "}", "if", "(", "...
Validates URL parsing results. @param array $urlParts
[ "Validates", "URL", "parsing", "results", "." ]
29995814d03987302c1690992f5a6e1221310d24
https://github.com/AlexaCRM/php-crm-toolkit/blob/29995814d03987302c1690992f5a6e1221310d24/src/Settings.php#L346-L358
train
AlexaCRM/php-crm-toolkit
src/SoapActions.php
SoapActions.setCachedSoapActions
private function setCachedSoapActions( $service, $soapActions ) { $cache = $this->client->cache; $cache->set( $service . "_soap_actions", $soapActions, 4*7*24*60*60 ); // four weeks }
php
private function setCachedSoapActions( $service, $soapActions ) { $cache = $this->client->cache; $cache->set( $service . "_soap_actions", $soapActions, 4*7*24*60*60 ); // four weeks }
[ "private", "function", "setCachedSoapActions", "(", "$", "service", ",", "$", "soapActions", ")", "{", "$", "cache", "=", "$", "this", "->", "client", "->", "cache", ";", "$", "cache", "->", "set", "(", "$", "service", ".", "\"_soap_actions\"", ",", "$",...
Sets Soap Actions to cache @param string $service @param SoapActions $soapActions
[ "Sets", "Soap", "Actions", "to", "cache" ]
29995814d03987302c1690992f5a6e1221310d24
https://github.com/AlexaCRM/php-crm-toolkit/blob/29995814d03987302c1690992f5a6e1221310d24/src/SoapActions.php#L67-L70
train
AlexaCRM/php-crm-toolkit
src/SoapActions.php
SoapActions.getCachedSoapActions
private function getCachedSoapActions( $service ) { $cache = $this->client->cache; $soapActions = $cache->get( $service . '_soap_actions' ); return $soapActions; }
php
private function getCachedSoapActions( $service ) { $cache = $this->client->cache; $soapActions = $cache->get( $service . '_soap_actions' ); return $soapActions; }
[ "private", "function", "getCachedSoapActions", "(", "$", "service", ")", "{", "$", "cache", "=", "$", "this", "->", "client", "->", "cache", ";", "$", "soapActions", "=", "$", "cache", "->", "get", "(", "$", "service", ".", "'_soap_actions'", ")", ";", ...
Retrieves Soap Actions from cache @param string $service @return array|null Soap Action array of strings, or NULL if action not cached
[ "Retrieves", "Soap", "Actions", "from", "cache" ]
29995814d03987302c1690992f5a6e1221310d24
https://github.com/AlexaCRM/php-crm-toolkit/blob/29995814d03987302c1690992f5a6e1221310d24/src/SoapActions.php#L79-L84
train
AlexaCRM/php-crm-toolkit
src/SoapActions.php
SoapActions.getSoapAction
public function getSoapAction( $service, $soapAction ) { /* Capitalize first char in action name */ $action = $soapAction; /* ucfirst(strtolower($soapAction)); */ /* Switch service for soap action */ switch ( strtolower( $service ) ) { case "organization": return $this->getOrganizationAction( $action ); break; case "discovery": return $this->getDiscoveryAction( $action ); break; default: throw new Exception( "Undefined service(" . $service . ") for soap action(" . $action . ")" ); } }
php
public function getSoapAction( $service, $soapAction ) { /* Capitalize first char in action name */ $action = $soapAction; /* ucfirst(strtolower($soapAction)); */ /* Switch service for soap action */ switch ( strtolower( $service ) ) { case "organization": return $this->getOrganizationAction( $action ); break; case "discovery": return $this->getDiscoveryAction( $action ); break; default: throw new Exception( "Undefined service(" . $service . ") for soap action(" . $action . ")" ); } }
[ "public", "function", "getSoapAction", "(", "$", "service", ",", "$", "soapAction", ")", "{", "/* Capitalize first char in action name */", "$", "action", "=", "$", "soapAction", ";", "/* ucfirst(strtolower($soapAction)); */", "/* Switch service for soap action */", "switch",...
Utility function to get the SoapAction @param string $service Dynamics CRM soap service, can be 'organization' or 'discovery' @param string $soapAction Action for soap method @return string @throws Exception
[ "Utility", "function", "to", "get", "the", "SoapAction" ]
29995814d03987302c1690992f5a6e1221310d24
https://github.com/AlexaCRM/php-crm-toolkit/blob/29995814d03987302c1690992f5a6e1221310d24/src/SoapActions.php#L95-L109
train
AlexaCRM/php-crm-toolkit
src/SoapActions.php
SoapActions.getAllDiscoverySoapActions
private function getAllDiscoverySoapActions() { /* If it is not cached, update the cache */ if ( $this->discoverySoapActions == null ) { $this->discoverySoapActions = self::getAllSoapActions( $this->client->getDiscoveryDOM(), 'DiscoveryService' ); $this->setCachedSoapActions( 'discovery', $this->discoverySoapActions ); } /* Return the cached value */ return $this->discoverySoapActions; }
php
private function getAllDiscoverySoapActions() { /* If it is not cached, update the cache */ if ( $this->discoverySoapActions == null ) { $this->discoverySoapActions = self::getAllSoapActions( $this->client->getDiscoveryDOM(), 'DiscoveryService' ); $this->setCachedSoapActions( 'discovery', $this->discoverySoapActions ); } /* Return the cached value */ return $this->discoverySoapActions; }
[ "private", "function", "getAllDiscoverySoapActions", "(", ")", "{", "/* If it is not cached, update the cache */", "if", "(", "$", "this", "->", "discoverySoapActions", "==", "null", ")", "{", "$", "this", "->", "discoverySoapActions", "=", "self", "::", "getAllSoapAc...
Get all the Operations & corresponding SoapActions for the DiscoveryService
[ "Get", "all", "the", "Operations", "&", "corresponding", "SoapActions", "for", "the", "DiscoveryService" ]
29995814d03987302c1690992f5a6e1221310d24
https://github.com/AlexaCRM/php-crm-toolkit/blob/29995814d03987302c1690992f5a6e1221310d24/src/SoapActions.php#L126-L136
train
AlexaCRM/php-crm-toolkit
src/SoapActions.php
SoapActions.getAllOrganizationSoapActions
private function getAllOrganizationSoapActions() { /* If it is not cached, update the cache */ if ( $this->organizationSoapActions == null ) { $this->organizationSoapActions = self::getAllSoapActions( $this->client->getOrganizationDOM(), 'OrganizationService' ); $this->setCachedSoapActions( 'organization', $this->organizationSoapActions ); } /* Return the cached value */ return $this->organizationSoapActions; }
php
private function getAllOrganizationSoapActions() { /* If it is not cached, update the cache */ if ( $this->organizationSoapActions == null ) { $this->organizationSoapActions = self::getAllSoapActions( $this->client->getOrganizationDOM(), 'OrganizationService' ); $this->setCachedSoapActions( 'organization', $this->organizationSoapActions ); } /* Return the cached value */ return $this->organizationSoapActions; }
[ "private", "function", "getAllOrganizationSoapActions", "(", ")", "{", "/* If it is not cached, update the cache */", "if", "(", "$", "this", "->", "organizationSoapActions", "==", "null", ")", "{", "$", "this", "->", "organizationSoapActions", "=", "self", "::", "get...
Get all the Operations & corresponding SoapActions for the OrganizationService
[ "Get", "all", "the", "Operations", "&", "corresponding", "SoapActions", "for", "the", "OrganizationService" ]
29995814d03987302c1690992f5a6e1221310d24
https://github.com/AlexaCRM/php-crm-toolkit/blob/29995814d03987302c1690992f5a6e1221310d24/src/SoapActions.php#L141-L151
train
AlexaCRM/php-crm-toolkit
src/Auth/OnlineFederation.php
OnlineFederation.getSTSUrl
protected function getSTSUrl( $login ) { $content = [ 'login' => $this->settings->username, 'xml' => 1 ]; $cURLHandle = curl_init(); curl_setopt( $cURLHandle, CURLOPT_URL, 'https://login.microsoftonline.com/GetUserRealm.srf' ); curl_setopt( $cURLHandle, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt( $cURLHandle, CURLOPT_TIMEOUT, Client::getConnectorTimeout() ); if ( $this->settings->caPath ) { curl_setopt( $cURLHandle, CURLOPT_CAINFO, $this->settings->caPath ); } if ( $this->settings->ignoreSslErrors ) { curl_setopt( $cURLHandle, CURLOPT_SSL_VERIFYPEER, 0 ); curl_setopt( $cURLHandle, CURLOPT_SSL_VERIFYHOST, 0 ); } curl_setopt( $cURLHandle, CURLOPT_SSLVERSION, defined( 'CURL_SSLVERSION_TLSv1_2' )? CURL_SSLVERSION_TLSv1_2 : 6 ); if( $this->settings->proxy ) { curl_setopt( $cURLHandle, CURLOPT_PROXY, $this->settings->proxy ); } curl_setopt( $cURLHandle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1 ); curl_setopt( $cURLHandle, CURLOPT_HTTPHEADER, [ 'Content-Type: application/x-www-form-urlencoded' ] ); curl_setopt( $cURLHandle, CURLOPT_POST, 1 ); curl_setopt( $cURLHandle, CURLOPT_POSTFIELDS, http_build_query( $content ) ); curl_setopt( $cURLHandle, CURLOPT_FOLLOWLOCATION, true ); // follow redirects curl_setopt( $cURLHandle, CURLOPT_POSTREDIR, 7 ); // 1 | 2 | 4 (301, 302, 303 redirects mask) curl_setopt( $cURLHandle, CURLOPT_HEADER, false ); /* Execute the cURL request, get the XML response */ $responseXML = curl_exec( $cURLHandle ); /* Check for cURL errors */ if ( curl_errno( $cURLHandle ) != CURLE_OK ) { throw new \Exception( 'cURL Error: ' . curl_error( $cURLHandle ) ); } /* Check for HTTP errors */ $httpResponse = curl_getinfo( $cURLHandle, CURLINFO_HTTP_CODE ); $curlInfo = curl_getinfo( $cURLHandle ); $curlErrNo = curl_errno( $cURLHandle ); curl_close( $cURLHandle ); if ( empty( $responseXML ) ) { throw new \Exception( 'Empty response from the GetUserRealm endpoint.' ); } if ( strpos( $responseXML, '<IsFederatedNS>true</IsFederatedNS>' ) === false ) { return null; } preg_match( '~<STSAuthURL>(.*?)</STSAuthURL>~', $responseXML, $stsMatch ); $authUri = $stsMatch[1]; return preg_replace( '~^https?://(.*?)/.*$~', 'https://$1/adfs/services/trust/13/usernamemixed', $authUri ); }
php
protected function getSTSUrl( $login ) { $content = [ 'login' => $this->settings->username, 'xml' => 1 ]; $cURLHandle = curl_init(); curl_setopt( $cURLHandle, CURLOPT_URL, 'https://login.microsoftonline.com/GetUserRealm.srf' ); curl_setopt( $cURLHandle, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt( $cURLHandle, CURLOPT_TIMEOUT, Client::getConnectorTimeout() ); if ( $this->settings->caPath ) { curl_setopt( $cURLHandle, CURLOPT_CAINFO, $this->settings->caPath ); } if ( $this->settings->ignoreSslErrors ) { curl_setopt( $cURLHandle, CURLOPT_SSL_VERIFYPEER, 0 ); curl_setopt( $cURLHandle, CURLOPT_SSL_VERIFYHOST, 0 ); } curl_setopt( $cURLHandle, CURLOPT_SSLVERSION, defined( 'CURL_SSLVERSION_TLSv1_2' )? CURL_SSLVERSION_TLSv1_2 : 6 ); if( $this->settings->proxy ) { curl_setopt( $cURLHandle, CURLOPT_PROXY, $this->settings->proxy ); } curl_setopt( $cURLHandle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1 ); curl_setopt( $cURLHandle, CURLOPT_HTTPHEADER, [ 'Content-Type: application/x-www-form-urlencoded' ] ); curl_setopt( $cURLHandle, CURLOPT_POST, 1 ); curl_setopt( $cURLHandle, CURLOPT_POSTFIELDS, http_build_query( $content ) ); curl_setopt( $cURLHandle, CURLOPT_FOLLOWLOCATION, true ); // follow redirects curl_setopt( $cURLHandle, CURLOPT_POSTREDIR, 7 ); // 1 | 2 | 4 (301, 302, 303 redirects mask) curl_setopt( $cURLHandle, CURLOPT_HEADER, false ); /* Execute the cURL request, get the XML response */ $responseXML = curl_exec( $cURLHandle ); /* Check for cURL errors */ if ( curl_errno( $cURLHandle ) != CURLE_OK ) { throw new \Exception( 'cURL Error: ' . curl_error( $cURLHandle ) ); } /* Check for HTTP errors */ $httpResponse = curl_getinfo( $cURLHandle, CURLINFO_HTTP_CODE ); $curlInfo = curl_getinfo( $cURLHandle ); $curlErrNo = curl_errno( $cURLHandle ); curl_close( $cURLHandle ); if ( empty( $responseXML ) ) { throw new \Exception( 'Empty response from the GetUserRealm endpoint.' ); } if ( strpos( $responseXML, '<IsFederatedNS>true</IsFederatedNS>' ) === false ) { return null; } preg_match( '~<STSAuthURL>(.*?)</STSAuthURL>~', $responseXML, $stsMatch ); $authUri = $stsMatch[1]; return preg_replace( '~^https?://(.*?)/.*$~', 'https://$1/adfs/services/trust/13/usernamemixed', $authUri ); }
[ "protected", "function", "getSTSUrl", "(", "$", "login", ")", "{", "$", "content", "=", "[", "'login'", "=>", "$", "this", "->", "settings", "->", "username", ",", "'xml'", "=>", "1", "]", ";", "$", "cURLHandle", "=", "curl_init", "(", ")", ";", "cur...
Retrieves the correct STS endpoint URL. Useful for federated AAD configurations. @param $login string @return null|string @throws \Exception
[ "Retrieves", "the", "correct", "STS", "endpoint", "URL", ".", "Useful", "for", "federated", "AAD", "configurations", "." ]
29995814d03987302c1690992f5a6e1221310d24
https://github.com/AlexaCRM/php-crm-toolkit/blob/29995814d03987302c1690992f5a6e1221310d24/src/Auth/OnlineFederation.php#L270-L326
train
fxpio/fxp-security
Listener/DisablePermissionSubscriber.php
DisablePermissionSubscriber.disablePermissionManager
public function disablePermissionManager(AbstractEditableSecurityEvent $event): void { $event->setPermissionEnabled($this->permManager->isEnabled()); $this->permManager->setEnabled(false); }
php
public function disablePermissionManager(AbstractEditableSecurityEvent $event): void { $event->setPermissionEnabled($this->permManager->isEnabled()); $this->permManager->setEnabled(false); }
[ "public", "function", "disablePermissionManager", "(", "AbstractEditableSecurityEvent", "$", "event", ")", ":", "void", "{", "$", "event", "->", "setPermissionEnabled", "(", "$", "this", "->", "permManager", "->", "isEnabled", "(", ")", ")", ";", "$", "this", ...
Disable the permission manager. @param AbstractEditableSecurityEvent $event The event
[ "Disable", "the", "permission", "manager", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Listener/DisablePermissionSubscriber.php#L61-L65
train
fxpio/fxp-security
Firewall/HostRoleListener.php
HostRoleListener.getHostRole
protected function getHostRole(GetResponseEvent $event) { $hostRole = null; $hostname = $event->getRequest()->getHttpHost(); foreach ($this->config as $hostPattern => $role) { if ($this->isValid($hostPattern, $hostname)) { $hostRole = $role; break; } } return $hostRole; }
php
protected function getHostRole(GetResponseEvent $event) { $hostRole = null; $hostname = $event->getRequest()->getHttpHost(); foreach ($this->config as $hostPattern => $role) { if ($this->isValid($hostPattern, $hostname)) { $hostRole = $role; break; } } return $hostRole; }
[ "protected", "function", "getHostRole", "(", "GetResponseEvent", "$", "event", ")", "{", "$", "hostRole", "=", "null", ";", "$", "hostname", "=", "$", "event", "->", "getRequest", "(", ")", "->", "getHttpHost", "(", ")", ";", "foreach", "(", "$", "this",...
Get the host role. @param GetResponseEvent $event The response event @return null|string
[ "Get", "the", "host", "role", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Firewall/HostRoleListener.php#L46-L60
train
fxpio/fxp-security
Firewall/HostRoleListener.php
HostRoleListener.isValid
private function isValid($pattern, $hostname) { return 0 === strpos($pattern, '/') && (1 + strrpos($pattern, '/')) === \strlen($pattern) ? (bool) preg_match($pattern, $hostname) : fnmatch($pattern, $hostname); }
php
private function isValid($pattern, $hostname) { return 0 === strpos($pattern, '/') && (1 + strrpos($pattern, '/')) === \strlen($pattern) ? (bool) preg_match($pattern, $hostname) : fnmatch($pattern, $hostname); }
[ "private", "function", "isValid", "(", "$", "pattern", ",", "$", "hostname", ")", "{", "return", "0", "===", "strpos", "(", "$", "pattern", ",", "'/'", ")", "&&", "(", "1", "+", "strrpos", "(", "$", "pattern", ",", "'/'", ")", ")", "===", "\\", "...
Check if the hostname matching with the host pattern. @param string $pattern The shell pattern or regex pattern starting and ending with a slash @param string $hostname The host name @return bool
[ "Check", "if", "the", "hostname", "matching", "with", "the", "host", "pattern", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Firewall/HostRoleListener.php#L70-L75
train
fxpio/fxp-security
Permission/PermissionManager.php
PermissionManager.validateRolePermissions
private function validateRolePermissions(RoleSecurityIdentity $sid, array $permissions, $subject = null, $class = null, $field = null) { $configOperations = $this->getConfigPermissionOperations($class, $field); foreach ($configOperations as $configOperation) { if (!isset($permissions[$configOperation])) { if (null !== $sp = $this->getConfigPermission($sid, $configOperation, $subject, $class, $field)) { $permissions[$sp->getPermission()->getOperation()] = $sp; continue; } throw new PermissionNotFoundException($configOperation, $class, $field); } } return array_values($permissions); }
php
private function validateRolePermissions(RoleSecurityIdentity $sid, array $permissions, $subject = null, $class = null, $field = null) { $configOperations = $this->getConfigPermissionOperations($class, $field); foreach ($configOperations as $configOperation) { if (!isset($permissions[$configOperation])) { if (null !== $sp = $this->getConfigPermission($sid, $configOperation, $subject, $class, $field)) { $permissions[$sp->getPermission()->getOperation()] = $sp; continue; } throw new PermissionNotFoundException($configOperation, $class, $field); } } return array_values($permissions); }
[ "private", "function", "validateRolePermissions", "(", "RoleSecurityIdentity", "$", "sid", ",", "array", "$", "permissions", ",", "$", "subject", "=", "null", ",", "$", "class", "=", "null", ",", "$", "field", "=", "null", ")", "{", "$", "configOperations", ...
Validate the role permissions. @param RoleSecurityIdentity $sid The role security identity @param PermissionChecking[] $permissions The permission checking @param null|FieldVote|object|string|SubjectIdentityInterface $subject The object or class name or field vote @param null|string $class The class name @param null|string $field The field name @return PermissionChecking[]
[ "Validate", "the", "role", "permissions", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Permission/PermissionManager.php#L178-L195
train
fxpio/fxp-security
Permission/PermissionManager.php
PermissionManager.getConfigPermission
private function getConfigPermission(RoleSecurityIdentity $sid, $operation, $subject = null, $class = null, $field = null) { $sps = $this->getConfigPermissions(); $field = null !== $field ? PermissionProviderInterface::CONFIG_FIELD : null; $fieldAction = PermissionUtils::getMapAction($field); $pc = null; if (isset($sps[PermissionProviderInterface::CONFIG_CLASS][$fieldAction][$operation])) { $sp = $sps[PermissionProviderInterface::CONFIG_CLASS][$fieldAction][$operation]; $pc = new PermissionChecking($sp, $this->isConfigGranted($sid, $operation, $subject, $class), true); } return $pc; }
php
private function getConfigPermission(RoleSecurityIdentity $sid, $operation, $subject = null, $class = null, $field = null) { $sps = $this->getConfigPermissions(); $field = null !== $field ? PermissionProviderInterface::CONFIG_FIELD : null; $fieldAction = PermissionUtils::getMapAction($field); $pc = null; if (isset($sps[PermissionProviderInterface::CONFIG_CLASS][$fieldAction][$operation])) { $sp = $sps[PermissionProviderInterface::CONFIG_CLASS][$fieldAction][$operation]; $pc = new PermissionChecking($sp, $this->isConfigGranted($sid, $operation, $subject, $class), true); } return $pc; }
[ "private", "function", "getConfigPermission", "(", "RoleSecurityIdentity", "$", "sid", ",", "$", "operation", ",", "$", "subject", "=", "null", ",", "$", "class", "=", "null", ",", "$", "field", "=", "null", ")", "{", "$", "sps", "=", "$", "this", "->"...
Get the config permission. @param RoleSecurityIdentity $sid The role security identity @param string $operation The operation @param null|FieldVote|object|string|SubjectIdentityInterface $subject The object or class name or field vote @param null|string $class The class name @param null|string $field The field name @return null|PermissionChecking
[ "Get", "the", "config", "permission", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Permission/PermissionManager.php#L208-L221
train
fxpio/fxp-security
Permission/PermissionManager.php
PermissionManager.isConfigGranted
private function isConfigGranted(RoleSecurityIdentity $sid, $operation, $subject = null, $class = null) { $granted = true; if (null !== $class && $this->hasConfig($class)) { $config = $this->getConfig($class); if (null !== $config->getMaster()) { $realOperation = $config->getMappingPermission($operation); $granted = $this->isGranted([$sid], [$realOperation], $subject); } } return $granted; }
php
private function isConfigGranted(RoleSecurityIdentity $sid, $operation, $subject = null, $class = null) { $granted = true; if (null !== $class && $this->hasConfig($class)) { $config = $this->getConfig($class); if (null !== $config->getMaster()) { $realOperation = $config->getMappingPermission($operation); $granted = $this->isGranted([$sid], [$realOperation], $subject); } } return $granted; }
[ "private", "function", "isConfigGranted", "(", "RoleSecurityIdentity", "$", "sid", ",", "$", "operation", ",", "$", "subject", "=", "null", ",", "$", "class", "=", "null", ")", "{", "$", "granted", "=", "true", ";", "if", "(", "null", "!==", "$", "clas...
Check if the config permission is granted. @param RoleSecurityIdentity $sid The role security identity @param string $operation The operation @param null|FieldVote|object|string|SubjectIdentityInterface $subject The object or class name or field vote @param null|string $class The class name @return bool
[ "Check", "if", "the", "config", "permission", "is", "granted", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Permission/PermissionManager.php#L233-L247
train
fxpio/fxp-security
Permission/PermissionManager.php
PermissionManager.getConfigPermissions
private function getConfigPermissions() { if (null === $this->cacheConfigPermissions) { $sps = $this->provider->getConfigPermissions(); $this->cacheConfigPermissions = []; foreach ($sps as $sp) { $classAction = PermissionUtils::getMapAction($sp->getClass()); $fieldAction = PermissionUtils::getMapAction($sp->getField()); $this->cacheConfigPermissions[$classAction][$fieldAction][$sp->getOperation()] = $sp; } } return $this->cacheConfigPermissions; }
php
private function getConfigPermissions() { if (null === $this->cacheConfigPermissions) { $sps = $this->provider->getConfigPermissions(); $this->cacheConfigPermissions = []; foreach ($sps as $sp) { $classAction = PermissionUtils::getMapAction($sp->getClass()); $fieldAction = PermissionUtils::getMapAction($sp->getField()); $this->cacheConfigPermissions[$classAction][$fieldAction][$sp->getOperation()] = $sp; } } return $this->cacheConfigPermissions; }
[ "private", "function", "getConfigPermissions", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "cacheConfigPermissions", ")", "{", "$", "sps", "=", "$", "this", "->", "provider", "->", "getConfigPermissions", "(", ")", ";", "$", "this", "->", ...
Get the config permissions. @return array
[ "Get", "the", "config", "permissions", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Permission/PermissionManager.php#L254-L268
train
fxpio/fxp-security
Permission/PermissionManager.php
PermissionManager.doIsGrantedPermission
private function doIsGrantedPermission($id, array $sids, $operation, $subject = null, $field = null) { $event = new CheckPermissionEvent($sids, $this->cache[$id], $operation, $subject, $field); $this->dispatcher->dispatch(PermissionEvents::CHECK_PERMISSION, $event); if (\is_bool($event->isGranted())) { return $event->isGranted(); } $classAction = PermissionUtils::getMapAction(null !== $subject ? $subject->getType() : null); $fieldAction = PermissionUtils::getMapAction($field); return isset($this->cache[$id][$classAction][$fieldAction][$operation]) || $this->isSharingGranted($operation, $subject, $field); }
php
private function doIsGrantedPermission($id, array $sids, $operation, $subject = null, $field = null) { $event = new CheckPermissionEvent($sids, $this->cache[$id], $operation, $subject, $field); $this->dispatcher->dispatch(PermissionEvents::CHECK_PERMISSION, $event); if (\is_bool($event->isGranted())) { return $event->isGranted(); } $classAction = PermissionUtils::getMapAction(null !== $subject ? $subject->getType() : null); $fieldAction = PermissionUtils::getMapAction($field); return isset($this->cache[$id][$classAction][$fieldAction][$operation]) || $this->isSharingGranted($operation, $subject, $field); }
[ "private", "function", "doIsGrantedPermission", "(", "$", "id", ",", "array", "$", "sids", ",", "$", "operation", ",", "$", "subject", "=", "null", ",", "$", "field", "=", "null", ")", "{", "$", "event", "=", "new", "CheckPermissionEvent", "(", "$", "s...
Action to determine whether access is granted for a specific operation. @param string $id The cache id @param SecurityIdentityInterface[] $sids The security identities @param string $operation The operation @param null|SubjectIdentityInterface $subject The subject @param null|string $field The field of subject @return bool
[ "Action", "to", "determine", "whether", "access", "is", "granted", "for", "a", "specific", "operation", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Permission/PermissionManager.php#L281-L295
train
fxpio/fxp-security
Permission/PermissionManager.php
PermissionManager.preloadSharingRolePermissions
private function preloadSharingRolePermissions(array $subjects): void { if (null !== $this->sharingManager) { $this->sharingManager->preloadRolePermissions($subjects); } }
php
private function preloadSharingRolePermissions(array $subjects): void { if (null !== $this->sharingManager) { $this->sharingManager->preloadRolePermissions($subjects); } }
[ "private", "function", "preloadSharingRolePermissions", "(", "array", "$", "subjects", ")", ":", "void", "{", "if", "(", "null", "!==", "$", "this", "->", "sharingManager", ")", "{", "$", "this", "->", "sharingManager", "->", "preloadRolePermissions", "(", "$"...
Load the permissions of sharing roles. @param SubjectIdentityInterface[] $subjects The subjects
[ "Load", "the", "permissions", "of", "sharing", "roles", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Permission/PermissionManager.php#L302-L307
train
fxpio/fxp-security
Permission/PermissionManager.php
PermissionManager.loadPermissions
private function loadPermissions(array $sids) { $roles = IdentityUtils::filterRolesIdentities($sids); $id = implode('|', $roles); if (!\array_key_exists($id, $this->cache)) { $this->cache[$id] = []; $preEvent = new PreLoadPermissionsEvent($sids, $roles); $this->dispatcher->dispatch(PermissionEvents::PRE_LOAD, $preEvent); $perms = $this->provider->getPermissions($roles); $this->buildSystemPermissions($id); foreach ($perms as $perm) { $class = PermissionUtils::getMapAction($perm->getClass()); $field = PermissionUtils::getMapAction($perm->getField()); $this->cache[$id][$class][$field][$perm->getOperation()] = true; } $postEvent = new PostLoadPermissionsEvent($sids, $roles, $this->cache[$id]); $this->dispatcher->dispatch(PermissionEvents::POST_LOAD, $postEvent); $this->cache[$id] = $postEvent->getPermissionMap(); } return $id; }
php
private function loadPermissions(array $sids) { $roles = IdentityUtils::filterRolesIdentities($sids); $id = implode('|', $roles); if (!\array_key_exists($id, $this->cache)) { $this->cache[$id] = []; $preEvent = new PreLoadPermissionsEvent($sids, $roles); $this->dispatcher->dispatch(PermissionEvents::PRE_LOAD, $preEvent); $perms = $this->provider->getPermissions($roles); $this->buildSystemPermissions($id); foreach ($perms as $perm) { $class = PermissionUtils::getMapAction($perm->getClass()); $field = PermissionUtils::getMapAction($perm->getField()); $this->cache[$id][$class][$field][$perm->getOperation()] = true; } $postEvent = new PostLoadPermissionsEvent($sids, $roles, $this->cache[$id]); $this->dispatcher->dispatch(PermissionEvents::POST_LOAD, $postEvent); $this->cache[$id] = $postEvent->getPermissionMap(); } return $id; }
[ "private", "function", "loadPermissions", "(", "array", "$", "sids", ")", "{", "$", "roles", "=", "IdentityUtils", "::", "filterRolesIdentities", "(", "$", "sids", ")", ";", "$", "id", "=", "implode", "(", "'|'", ",", "$", "roles", ")", ";", "if", "(",...
Load the permissions of roles and returns the id of cache. @param SecurityIdentityInterface[] $sids The security identities @return string
[ "Load", "the", "permissions", "of", "roles", "and", "returns", "the", "id", "of", "cache", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Permission/PermissionManager.php#L316-L341
train
fxpio/fxp-security
Permission/PermissionManager.php
PermissionManager.isConfigPermission
private function isConfigPermission($operation, $class = null, $field = null) { $map = $this->getMapConfigPermissions(); $class = PermissionUtils::getMapAction($class); $field = PermissionUtils::getMapAction($field); return isset($map[$class][$field][$operation]); }
php
private function isConfigPermission($operation, $class = null, $field = null) { $map = $this->getMapConfigPermissions(); $class = PermissionUtils::getMapAction($class); $field = PermissionUtils::getMapAction($field); return isset($map[$class][$field][$operation]); }
[ "private", "function", "isConfigPermission", "(", "$", "operation", ",", "$", "class", "=", "null", ",", "$", "field", "=", "null", ")", "{", "$", "map", "=", "$", "this", "->", "getMapConfigPermissions", "(", ")", ";", "$", "class", "=", "PermissionUtil...
Check if the permission operation is defined by the config. @param string $operation The permission operation @param null|string $class The class name @param null|string $field The field @return bool
[ "Check", "if", "the", "permission", "operation", "is", "defined", "by", "the", "config", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Permission/PermissionManager.php#L352-L359
train
fxpio/fxp-security
Permission/PermissionManager.php
PermissionManager.getConfigPermissionOperations
private function getConfigPermissionOperations($class = null, $field = null) { $map = $this->getMapConfigPermissions(); $class = PermissionUtils::getMapAction($class); $field = PermissionUtils::getMapAction($field); $operations = []; if (isset($map[$class][$field])) { $operations = array_keys($map[$class][$field]); } return $operations; }
php
private function getConfigPermissionOperations($class = null, $field = null) { $map = $this->getMapConfigPermissions(); $class = PermissionUtils::getMapAction($class); $field = PermissionUtils::getMapAction($field); $operations = []; if (isset($map[$class][$field])) { $operations = array_keys($map[$class][$field]); } return $operations; }
[ "private", "function", "getConfigPermissionOperations", "(", "$", "class", "=", "null", ",", "$", "field", "=", "null", ")", "{", "$", "map", "=", "$", "this", "->", "getMapConfigPermissions", "(", ")", ";", "$", "class", "=", "PermissionUtils", "::", "get...
Get the config operations of the subject. @param null|string $class The class name @param null|string $field The field @return string[]
[ "Get", "the", "config", "operations", "of", "the", "subject", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Permission/PermissionManager.php#L369-L381
train
fxpio/fxp-security
Permission/PermissionManager.php
PermissionManager.getMapConfigPermissions
private function getMapConfigPermissions() { $id = '_config'; if (!\array_key_exists($id, $this->cache)) { $this->cache[$id] = []; $this->buildSystemPermissions($id); } return $this->cache[$id]; }
php
private function getMapConfigPermissions() { $id = '_config'; if (!\array_key_exists($id, $this->cache)) { $this->cache[$id] = []; $this->buildSystemPermissions($id); } return $this->cache[$id]; }
[ "private", "function", "getMapConfigPermissions", "(", ")", "{", "$", "id", "=", "'_config'", ";", "if", "(", "!", "\\", "array_key_exists", "(", "$", "id", ",", "$", "this", "->", "cache", ")", ")", "{", "$", "this", "->", "cache", "[", "$", "id", ...
Get the map of the config permissions. @return array
[ "Get", "the", "map", "of", "the", "config", "permissions", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Permission/PermissionManager.php#L388-L398
train
fxpio/fxp-security
Permission/PermissionManager.php
PermissionManager.buildSystemPermissions
private function buildSystemPermissions($id): void { foreach ($this->configs as $config) { foreach ($config->getOperations() as $operation) { $field = PermissionUtils::getMapAction(null); $this->cache[$id][$config->getType()][$field][$operation] = true; } foreach ($config->getFields() as $fieldConfig) { foreach ($fieldConfig->getOperations() as $operation) { $this->cache[$id][$config->getType()][$fieldConfig->getField()][$operation] = true; } } } }
php
private function buildSystemPermissions($id): void { foreach ($this->configs as $config) { foreach ($config->getOperations() as $operation) { $field = PermissionUtils::getMapAction(null); $this->cache[$id][$config->getType()][$field][$operation] = true; } foreach ($config->getFields() as $fieldConfig) { foreach ($fieldConfig->getOperations() as $operation) { $this->cache[$id][$config->getType()][$fieldConfig->getField()][$operation] = true; } } } }
[ "private", "function", "buildSystemPermissions", "(", "$", "id", ")", ":", "void", "{", "foreach", "(", "$", "this", "->", "configs", "as", "$", "config", ")", "{", "foreach", "(", "$", "config", "->", "getOperations", "(", ")", "as", "$", "operation", ...
Build the system permissions. @param string $id The cache id
[ "Build", "the", "system", "permissions", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Permission/PermissionManager.php#L405-L419
train
fxpio/fxp-security
Sharing/SharingUtils.php
SharingUtils.buildOperations
public static function buildOperations(SharingInterface $sharing) { $operations = []; foreach ($sharing->getPermissions() as $permission) { $operations[] = $permission->getOperation(); } return $operations; }
php
public static function buildOperations(SharingInterface $sharing) { $operations = []; foreach ($sharing->getPermissions() as $permission) { $operations[] = $permission->getOperation(); } return $operations; }
[ "public", "static", "function", "buildOperations", "(", "SharingInterface", "$", "sharing", ")", "{", "$", "operations", "=", "[", "]", ";", "foreach", "(", "$", "sharing", "->", "getPermissions", "(", ")", "as", "$", "permission", ")", "{", "$", "operatio...
Build the operations of sharing entry. @param SharingInterface $sharing The sharing entry @return string[]
[ "Build", "the", "operations", "of", "sharing", "entry", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Sharing/SharingUtils.php#L31-L40
train
fxpio/fxp-security
Doctrine/ORM/Listener/SharingDeleteListener.php
SharingDeleteListener.postFlush
public function postFlush(PostFlushEventArgs $args): void { if (!empty($this->deleteSharingSubjects) || !empty($this->deleteSharingIdentities)) { $this->buildDeleteQuery($args->getEntityManager())->execute(); } $this->deleteSharingSubjects = []; $this->deleteSharingIdentities = []; }
php
public function postFlush(PostFlushEventArgs $args): void { if (!empty($this->deleteSharingSubjects) || !empty($this->deleteSharingIdentities)) { $this->buildDeleteQuery($args->getEntityManager())->execute(); } $this->deleteSharingSubjects = []; $this->deleteSharingIdentities = []; }
[ "public", "function", "postFlush", "(", "PostFlushEventArgs", "$", "args", ")", ":", "void", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "deleteSharingSubjects", ")", "||", "!", "empty", "(", "$", "this", "->", "deleteSharingIdentities", ")", ")"...
Post flush action. @param PostFlushEventArgs $args The event
[ "Post", "flush", "action", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Doctrine/ORM/Listener/SharingDeleteListener.php#L109-L117
train
fxpio/fxp-security
Doctrine/ORM/Listener/SharingDeleteListener.php
SharingDeleteListener.buildDeleteQuery
private function buildDeleteQuery(EntityManagerInterface $em) { $qb = $em->createQueryBuilder() ->delete($this->sharingClass, 's') ; $this->buildCriteria($qb, $this->deleteSharingSubjects, 'subjectClass', 'subjectId'); $this->buildCriteria($qb, $this->deleteSharingIdentities, 'identityClass', 'identityName'); return $qb->getQuery(); }
php
private function buildDeleteQuery(EntityManagerInterface $em) { $qb = $em->createQueryBuilder() ->delete($this->sharingClass, 's') ; $this->buildCriteria($qb, $this->deleteSharingSubjects, 'subjectClass', 'subjectId'); $this->buildCriteria($qb, $this->deleteSharingIdentities, 'identityClass', 'identityName'); return $qb->getQuery(); }
[ "private", "function", "buildDeleteQuery", "(", "EntityManagerInterface", "$", "em", ")", "{", "$", "qb", "=", "$", "em", "->", "createQueryBuilder", "(", ")", "->", "delete", "(", "$", "this", "->", "sharingClass", ",", "'s'", ")", ";", "$", "this", "->...
Build the delete query. @param EntityManagerInterface $em The entity manager @return Query
[ "Build", "the", "delete", "query", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Doctrine/ORM/Listener/SharingDeleteListener.php#L168-L178
train
fxpio/fxp-security
Doctrine/ORM/Listener/SharingDeleteListener.php
SharingDeleteListener.buildCriteria
private function buildCriteria(QueryBuilder $qb, array $mapIds, $fieldClass, $fieldId): void { if (!empty($mapIds)) { $where = ''; $parameters = []; $i = 0; foreach ($mapIds as $type => $identifiers) { $pClass = $fieldClass.'_'.$i; $pIdentifiers = $fieldId.'s_'.$i; $parameters[$pClass] = $type; $parameters[$pIdentifiers] = $identifiers; $where .= '' === $where ? '' : ' OR '; $where .= sprintf('(s.%s = :%s AND s.%s IN (:%s))', $fieldClass, $pClass, $fieldId, $pIdentifiers); ++$i; } $qb->andWhere($where); foreach ($parameters as $key => $identifiers) { $qb->setParameter($key, $identifiers); } } }
php
private function buildCriteria(QueryBuilder $qb, array $mapIds, $fieldClass, $fieldId): void { if (!empty($mapIds)) { $where = ''; $parameters = []; $i = 0; foreach ($mapIds as $type => $identifiers) { $pClass = $fieldClass.'_'.$i; $pIdentifiers = $fieldId.'s_'.$i; $parameters[$pClass] = $type; $parameters[$pIdentifiers] = $identifiers; $where .= '' === $where ? '' : ' OR '; $where .= sprintf('(s.%s = :%s AND s.%s IN (:%s))', $fieldClass, $pClass, $fieldId, $pIdentifiers); ++$i; } $qb->andWhere($where); foreach ($parameters as $key => $identifiers) { $qb->setParameter($key, $identifiers); } } }
[ "private", "function", "buildCriteria", "(", "QueryBuilder", "$", "qb", ",", "array", "$", "mapIds", ",", "$", "fieldClass", ",", "$", "fieldId", ")", ":", "void", "{", "if", "(", "!", "empty", "(", "$", "mapIds", ")", ")", "{", "$", "where", "=", ...
Build the query criteria. @param QueryBuilder $qb The query builder @param array $mapIds The map of classname and identifiers @param string $fieldClass The name of field class @param string $fieldId The name of field identifier
[ "Build", "the", "query", "criteria", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Doctrine/ORM/Listener/SharingDeleteListener.php#L188-L211
train
fxpio/fxp-security
Doctrine/DoctrineUtils.php
DoctrineUtils.getIdentifier
public static function getIdentifier(ClassMetadata $targetEntity) { if (!isset(self::$cacheIdentifiers[$targetEntity->getName()])) { $identifier = $targetEntity->getIdentifierFieldNames(); self::$cacheIdentifiers[$targetEntity->getName()] = 0 < \count($identifier) ? $identifier[0] : 'id'; } return self::$cacheIdentifiers[$targetEntity->getName()]; }
php
public static function getIdentifier(ClassMetadata $targetEntity) { if (!isset(self::$cacheIdentifiers[$targetEntity->getName()])) { $identifier = $targetEntity->getIdentifierFieldNames(); self::$cacheIdentifiers[$targetEntity->getName()] = 0 < \count($identifier) ? $identifier[0] : 'id'; } return self::$cacheIdentifiers[$targetEntity->getName()]; }
[ "public", "static", "function", "getIdentifier", "(", "ClassMetadata", "$", "targetEntity", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "cacheIdentifiers", "[", "$", "targetEntity", "->", "getName", "(", ")", "]", ")", ")", "{", "$", "iden...
Get the identifier of entity. @param ClassMetadata $targetEntity The target entity @return string
[ "Get", "the", "identifier", "of", "entity", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Doctrine/DoctrineUtils.php#L67-L77
train
fxpio/fxp-security
Doctrine/DoctrineUtils.php
DoctrineUtils.getMockZeroId
public static function getMockZeroId(ClassMetadata $targetEntity) { if (!isset(self::$cacheZeroIds[$targetEntity->getName()])) { $type = self::getIdentifierType($targetEntity); self::$cacheZeroIds[$targetEntity->getName()] = self::findZeroIdValue($type); } return self::$cacheZeroIds[$targetEntity->getName()]; }
php
public static function getMockZeroId(ClassMetadata $targetEntity) { if (!isset(self::$cacheZeroIds[$targetEntity->getName()])) { $type = self::getIdentifierType($targetEntity); self::$cacheZeroIds[$targetEntity->getName()] = self::findZeroIdValue($type); } return self::$cacheZeroIds[$targetEntity->getName()]; }
[ "public", "static", "function", "getMockZeroId", "(", "ClassMetadata", "$", "targetEntity", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "cacheZeroIds", "[", "$", "targetEntity", "->", "getName", "(", ")", "]", ")", ")", "{", "$", "type", ...
Get the mock id for entity identifier. @param ClassMetadata $targetEntity The target entity @return null|int|string
[ "Get", "the", "mock", "id", "for", "entity", "identifier", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Doctrine/DoctrineUtils.php#L86-L94
train
fxpio/fxp-security
Doctrine/DoctrineUtils.php
DoctrineUtils.castIdentifier
public static function castIdentifier(ClassMetadata $targetEntity, Connection $connection) { if (!isset(self::$cacheCastIdentifiers[$targetEntity->getName()])) { $cast = ''; if ($connection->getDriver() instanceof PgSqlDriver) { $type = self::getIdentifierType($targetEntity); $cast = '::'.$type->getSQLDeclaration( $targetEntity->getIdentifierFieldNames(), $connection->getDatabasePlatform() ); } self::$cacheCastIdentifiers[$targetEntity->getName()] = $cast; } return self::$cacheCastIdentifiers[$targetEntity->getName()]; }
php
public static function castIdentifier(ClassMetadata $targetEntity, Connection $connection) { if (!isset(self::$cacheCastIdentifiers[$targetEntity->getName()])) { $cast = ''; if ($connection->getDriver() instanceof PgSqlDriver) { $type = self::getIdentifierType($targetEntity); $cast = '::'.$type->getSQLDeclaration( $targetEntity->getIdentifierFieldNames(), $connection->getDatabasePlatform() ); } self::$cacheCastIdentifiers[$targetEntity->getName()] = $cast; } return self::$cacheCastIdentifiers[$targetEntity->getName()]; }
[ "public", "static", "function", "castIdentifier", "(", "ClassMetadata", "$", "targetEntity", ",", "Connection", "$", "connection", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "cacheCastIdentifiers", "[", "$", "targetEntity", "->", "getName", "("...
Cast the identifier. @param ClassMetadata $targetEntity The target entity @param Connection $connection The doctrine connection @return string
[ "Cast", "the", "identifier", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Doctrine/DoctrineUtils.php#L104-L121
train
fxpio/fxp-security
Doctrine/DoctrineUtils.php
DoctrineUtils.getIdentifierType
public static function getIdentifierType(ClassMetadata $targetEntity) { $identifier = self::getIdentifier($targetEntity); $type = $targetEntity->getTypeOfField($identifier); if ($type instanceof Type) { return $type; } if (\is_string($type)) { return Type::getType($type); } $msg = 'The Doctrine DBAL type is not found for "%s::%s" identifier'; throw new RuntimeException(sprintf($msg, $targetEntity->getName(), $identifier)); }
php
public static function getIdentifierType(ClassMetadata $targetEntity) { $identifier = self::getIdentifier($targetEntity); $type = $targetEntity->getTypeOfField($identifier); if ($type instanceof Type) { return $type; } if (\is_string($type)) { return Type::getType($type); } $msg = 'The Doctrine DBAL type is not found for "%s::%s" identifier'; throw new RuntimeException(sprintf($msg, $targetEntity->getName(), $identifier)); }
[ "public", "static", "function", "getIdentifierType", "(", "ClassMetadata", "$", "targetEntity", ")", "{", "$", "identifier", "=", "self", "::", "getIdentifier", "(", "$", "targetEntity", ")", ";", "$", "type", "=", "$", "targetEntity", "->", "getTypeOfField", ...
Get the dbal identifier type. @param ClassMetadata $targetEntity The target entity @throws RuntimeException When the doctrine dbal type is not found @return Type
[ "Get", "the", "dbal", "identifier", "type", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Doctrine/DoctrineUtils.php#L132-L148
train
fxpio/fxp-security
Doctrine/DoctrineUtils.php
DoctrineUtils.findZeroIdValue
private static function findZeroIdValue(Type $type) { if ($type instanceof GuidType) { $value = '00000000-0000-0000-0000-000000000000'; } elseif (self::isNumberType($type)) { $value = 0; } elseif (self::isStringType($type)) { $value = ''; } else { $value = null; } return $value; }
php
private static function findZeroIdValue(Type $type) { if ($type instanceof GuidType) { $value = '00000000-0000-0000-0000-000000000000'; } elseif (self::isNumberType($type)) { $value = 0; } elseif (self::isStringType($type)) { $value = ''; } else { $value = null; } return $value; }
[ "private", "static", "function", "findZeroIdValue", "(", "Type", "$", "type", ")", "{", "if", "(", "$", "type", "instanceof", "GuidType", ")", "{", "$", "value", "=", "'00000000-0000-0000-0000-000000000000'", ";", "}", "elseif", "(", "self", "::", "isNumberTyp...
Find the zero id by identifier type. @param Type $type The dbal identifier type @return null|int|string
[ "Find", "the", "zero", "id", "by", "identifier", "type", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Doctrine/DoctrineUtils.php#L157-L170
train
fxpio/fxp-security
Doctrine/DoctrineUtils.php
DoctrineUtils.isNumberType
private static function isNumberType(Type $type) { return $type instanceof IntegerType || $type instanceof SmallIntType || $type instanceof BigIntType || $type instanceof DecimalType || $type instanceof FloatType; }
php
private static function isNumberType(Type $type) { return $type instanceof IntegerType || $type instanceof SmallIntType || $type instanceof BigIntType || $type instanceof DecimalType || $type instanceof FloatType; }
[ "private", "static", "function", "isNumberType", "(", "Type", "$", "type", ")", "{", "return", "$", "type", "instanceof", "IntegerType", "||", "$", "type", "instanceof", "SmallIntType", "||", "$", "type", "instanceof", "BigIntType", "||", "$", "type", "instanc...
Check if the type is a number type. @param Type $type The dbal identifier type @return bool
[ "Check", "if", "the", "type", "is", "a", "number", "type", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Doctrine/DoctrineUtils.php#L179-L182
train
fxpio/fxp-security
Permission/AbstractPermissionManager.php
AbstractPermissionManager.buildContexts
protected function buildContexts(RoleInterface $role) { $contexts = null; if ($role instanceof OrganizationalInterface) { $contexts = [null !== $role->getOrganization() ? PermissionContexts::ORGANIZATION_ROLE : PermissionContexts::ROLE]; } return $contexts; }
php
protected function buildContexts(RoleInterface $role) { $contexts = null; if ($role instanceof OrganizationalInterface) { $contexts = [null !== $role->getOrganization() ? PermissionContexts::ORGANIZATION_ROLE : PermissionContexts::ROLE]; } return $contexts; }
[ "protected", "function", "buildContexts", "(", "RoleInterface", "$", "role", ")", "{", "$", "contexts", "=", "null", ";", "if", "(", "$", "role", "instanceof", "OrganizationalInterface", ")", "{", "$", "contexts", "=", "[", "null", "!==", "$", "role", "->"...
Build the permission contexts for the role. @param RoleInterface $role The role @return null|string[]
[ "Build", "the", "permission", "contexts", "for", "the", "role", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Permission/AbstractPermissionManager.php#L250-L259
train
fxpio/fxp-security
Permission/AbstractPermissionManager.php
AbstractPermissionManager.getRealPermissions
private function getRealPermissions(array $permissions, $subject = null, $field = null) { if (null !== $subject && $this->hasConfig($subject->getType())) { $config = $this->getConfig($subject->getType()); if (null !== $field && $config->hasField($field)) { $config = $config->getField($field); } foreach ($permissions as $key => &$permission) { $permission = $config->getMappingPermission($permission); } } return $permissions; }
php
private function getRealPermissions(array $permissions, $subject = null, $field = null) { if (null !== $subject && $this->hasConfig($subject->getType())) { $config = $this->getConfig($subject->getType()); if (null !== $field && $config->hasField($field)) { $config = $config->getField($field); } foreach ($permissions as $key => &$permission) { $permission = $config->getMappingPermission($permission); } } return $permissions; }
[ "private", "function", "getRealPermissions", "(", "array", "$", "permissions", ",", "$", "subject", "=", "null", ",", "$", "field", "=", "null", ")", "{", "if", "(", "null", "!==", "$", "subject", "&&", "$", "this", "->", "hasConfig", "(", "$", "subjec...
Get the real permissions. @param string[] $permissions The permissions @param null|SubjectIdentityInterface $subject The subject identity @param null|string $field The field name @return string[]
[ "Get", "the", "real", "permissions", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Permission/AbstractPermissionManager.php#L311-L326
train
fxpio/fxp-security
Permission/AbstractPermissionManager.php
AbstractPermissionManager.getMasterPermissions
private function getMasterPermissions(array $permissions, $subject, $field) { $master = $this->getMaster($subject); if (null !== $subject && null !== $master && $subject !== $master) { if (null !== $field) { $permissions = $this->buildMasterFieldPermissions($subject, $permissions); } $subject = $master; $field = null; } return [$permissions, $subject, $field]; }
php
private function getMasterPermissions(array $permissions, $subject, $field) { $master = $this->getMaster($subject); if (null !== $subject && null !== $master && $subject !== $master) { if (null !== $field) { $permissions = $this->buildMasterFieldPermissions($subject, $permissions); } $subject = $master; $field = null; } return [$permissions, $subject, $field]; }
[ "private", "function", "getMasterPermissions", "(", "array", "$", "permissions", ",", "$", "subject", ",", "$", "field", ")", "{", "$", "master", "=", "$", "this", "->", "getMaster", "(", "$", "subject", ")", ";", "if", "(", "null", "!==", "$", "subjec...
Get the master subject and permissions. @param string[] $permissions The permissions @param null|SubjectIdentityInterface $subject The subject identity @param null|string $field The field name @return array
[ "Get", "the", "master", "subject", "and", "permissions", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Permission/AbstractPermissionManager.php#L337-L351
train
fxpio/fxp-security
Permission/AbstractPermissionManager.php
AbstractPermissionManager.buildMasterFieldPermissions
private function buildMasterFieldPermissions(SubjectIdentityInterface $subject, array $permissions) { if ($this->hasConfig($subject->getType())) { $map = $this->getConfig($subject->getType())->getMasterFieldMappingPermissions(); foreach ($permissions as &$permission) { if (false !== $key = array_search($permission, $map, true)) { $permission = $key; } } } return $permissions; }
php
private function buildMasterFieldPermissions(SubjectIdentityInterface $subject, array $permissions) { if ($this->hasConfig($subject->getType())) { $map = $this->getConfig($subject->getType())->getMasterFieldMappingPermissions(); foreach ($permissions as &$permission) { if (false !== $key = array_search($permission, $map, true)) { $permission = $key; } } } return $permissions; }
[ "private", "function", "buildMasterFieldPermissions", "(", "SubjectIdentityInterface", "$", "subject", ",", "array", "$", "permissions", ")", "{", "if", "(", "$", "this", "->", "hasConfig", "(", "$", "subject", "->", "getType", "(", ")", ")", ")", "{", "$", ...
Build the master permissions. @param SubjectIdentityInterface $subject The subject identity @param string[] $permissions The permissions @return string[]
[ "Build", "the", "master", "permissions", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Permission/AbstractPermissionManager.php#L361-L374
train
fxpio/fxp-security
Firewall/AnonymousRoleListener.php
AnonymousRoleListener.hasRole
private function hasRole() { return isset($this->config['role']) && \is_string($this->config['role']) && 0 === strpos($this->config['role'], 'ROLE_'); }
php
private function hasRole() { return isset($this->config['role']) && \is_string($this->config['role']) && 0 === strpos($this->config['role'], 'ROLE_'); }
[ "private", "function", "hasRole", "(", ")", "{", "return", "isset", "(", "$", "this", "->", "config", "[", "'role'", "]", ")", "&&", "\\", "is_string", "(", "$", "this", "->", "config", "[", "'role'", "]", ")", "&&", "0", "===", "strpos", "(", "$",...
Check if the anonymous role is present in config. @return bool
[ "Check", "if", "the", "anonymous", "role", "is", "present", "in", "config", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Firewall/AnonymousRoleListener.php#L73-L78
train
fxpio/fxp-security
Firewall/AnonymousRoleListener.php
AnonymousRoleListener.isAnonymous
private function isAnonymous() { $token = $this->tokenStorage->getToken(); return null === $token || $this->trustResolver->isAnonymous($token); }
php
private function isAnonymous() { $token = $this->tokenStorage->getToken(); return null === $token || $this->trustResolver->isAnonymous($token); }
[ "private", "function", "isAnonymous", "(", ")", "{", "$", "token", "=", "$", "this", "->", "tokenStorage", "->", "getToken", "(", ")", ";", "return", "null", "===", "$", "token", "||", "$", "this", "->", "trustResolver", "->", "isAnonymous", "(", "$", ...
Check if the token is a anonymous token. @return bool
[ "Check", "if", "the", "token", "is", "a", "anonymous", "token", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Firewall/AnonymousRoleListener.php#L85-L91
train
fxpio/fxp-security
Identity/RoleSecurityIdentity.php
RoleSecurityIdentity.fromAccount
public static function fromAccount($role) { return $role instanceof RoleInterface ? new self(ClassUtils::getClass($role), $role->getName()) : new self('role', $role); }
php
public static function fromAccount($role) { return $role instanceof RoleInterface ? new self(ClassUtils::getClass($role), $role->getName()) : new self('role', $role); }
[ "public", "static", "function", "fromAccount", "(", "$", "role", ")", "{", "return", "$", "role", "instanceof", "RoleInterface", "?", "new", "self", "(", "ClassUtils", "::", "getClass", "(", "$", "role", ")", ",", "$", "role", "->", "getName", "(", ")", ...
Creates a role security identity from a RoleInterface. @param RoleInterface|string $role The role @return self
[ "Creates", "a", "role", "security", "identity", "from", "a", "RoleInterface", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Identity/RoleSecurityIdentity.php#L32-L37
train
fxpio/fxp-security
Identity/RoleSecurityIdentity.php
RoleSecurityIdentity.fromToken
public static function fromToken(TokenInterface $token) { $user = $token->getUser(); if ($user instanceof RoleableInterface) { $sids = []; $roles = $user->getRoles(); foreach ($roles as $role) { $sids[] = self::fromAccount($role); } return $sids; } throw new InvalidArgumentException('The user class must implement "Fxp\Component\Security\Model\Traits\RoleableInterface"'); }
php
public static function fromToken(TokenInterface $token) { $user = $token->getUser(); if ($user instanceof RoleableInterface) { $sids = []; $roles = $user->getRoles(); foreach ($roles as $role) { $sids[] = self::fromAccount($role); } return $sids; } throw new InvalidArgumentException('The user class must implement "Fxp\Component\Security\Model\Traits\RoleableInterface"'); }
[ "public", "static", "function", "fromToken", "(", "TokenInterface", "$", "token", ")", "{", "$", "user", "=", "$", "token", "->", "getUser", "(", ")", ";", "if", "(", "$", "user", "instanceof", "RoleableInterface", ")", "{", "$", "sids", "=", "[", "]",...
Creates a role security identity from a TokenInterface. @param TokenInterface $token The token @throws InvalidArgumentException When the user class not implements "Fxp\Component\Security\Model\Traits\RoleableInterface" @return self[]
[ "Creates", "a", "role", "security", "identity", "from", "a", "TokenInterface", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Identity/RoleSecurityIdentity.php#L48-L64
train
fxpio/fxp-security
Permission/PermissionUtils.php
PermissionUtils.getSubjectAndField
public static function getSubjectAndField($subject, $optional = false) { if ($subject instanceof FieldVote) { $field = $subject->getField(); $subject = $subject->getSubject(); } else { if (null === $subject && !$optional) { throw new UnexpectedTypeException($subject, 'FieldVote|SubjectIdentityInterface|object|string'); } $field = null; $subject = null !== $subject ? SubjectUtils::getSubjectIdentity($subject) : null; } return [$subject, $field]; }
php
public static function getSubjectAndField($subject, $optional = false) { if ($subject instanceof FieldVote) { $field = $subject->getField(); $subject = $subject->getSubject(); } else { if (null === $subject && !$optional) { throw new UnexpectedTypeException($subject, 'FieldVote|SubjectIdentityInterface|object|string'); } $field = null; $subject = null !== $subject ? SubjectUtils::getSubjectIdentity($subject) : null; } return [$subject, $field]; }
[ "public", "static", "function", "getSubjectAndField", "(", "$", "subject", ",", "$", "optional", "=", "false", ")", "{", "if", "(", "$", "subject", "instanceof", "FieldVote", ")", "{", "$", "field", "=", "$", "subject", "->", "getField", "(", ")", ";", ...
Get the subject identity and field. @param null|FieldVote|object|string|SubjectIdentityInterface $subject The subject instance or classname @param bool $optional Check if the subject id optional @return array
[ "Get", "the", "subject", "identity", "and", "field", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Permission/PermissionUtils.php#L46-L63
train
fxpio/fxp-security
Permission/PermissionUtils.php
PermissionUtils.getClassAndField
public static function getClassAndField($subject, $optional = false) { /** @var null|SubjectIdentityInterface $subject */ list($subject, $field) = static::getSubjectAndField($subject, $optional); $class = null !== $subject ? $subject->getType() : null; return [$class, $field]; }
php
public static function getClassAndField($subject, $optional = false) { /** @var null|SubjectIdentityInterface $subject */ list($subject, $field) = static::getSubjectAndField($subject, $optional); $class = null !== $subject ? $subject->getType() : null; return [$class, $field]; }
[ "public", "static", "function", "getClassAndField", "(", "$", "subject", ",", "$", "optional", "=", "false", ")", "{", "/** @var null|SubjectIdentityInterface $subject */", "list", "(", "$", "subject", ",", "$", "field", ")", "=", "static", "::", "getSubjectAndFie...
Get the class and field. @param null|FieldVote|object|string|SubjectIdentityInterface $subject The subject instance or classname @param bool $optional Check if the subject id optional @return array
[ "Get", "the", "class", "and", "field", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Permission/PermissionUtils.php#L73-L83
train
fxpio/fxp-security
Authorization/Voter/AbstractIdentityVoter.php
AbstractIdentityVoter.isValidIdentity
protected function isValidIdentity($attribute, SecurityIdentityInterface $sid) { return ($this->getValidType() === $sid->getType() || \in_array($this->getValidType(), class_implements($sid->getType()), true)) && substr($attribute, \strlen($this->prefix)) === OrganizationalUtil::format($sid->getIdentifier()); }
php
protected function isValidIdentity($attribute, SecurityIdentityInterface $sid) { return ($this->getValidType() === $sid->getType() || \in_array($this->getValidType(), class_implements($sid->getType()), true)) && substr($attribute, \strlen($this->prefix)) === OrganizationalUtil::format($sid->getIdentifier()); }
[ "protected", "function", "isValidIdentity", "(", "$", "attribute", ",", "SecurityIdentityInterface", "$", "sid", ")", "{", "return", "(", "$", "this", "->", "getValidType", "(", ")", "===", "$", "sid", "->", "getType", "(", ")", "||", "\\", "in_array", "("...
Check if the security identity is valid for this voter. @param string $attribute The attribute @param SecurityIdentityInterface $sid The security identity @return bool
[ "Check", "if", "the", "security", "identity", "is", "valid", "for", "this", "voter", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Authorization/Voter/AbstractIdentityVoter.php#L81-L85
train
fxpio/fxp-security
Authorization/Voter/ExpressionVoter.php
ExpressionVoter.getVariables
protected function getVariables(TokenInterface $token, $subject) { $event = new GetExpressionVariablesEvent($token); $this->dispatcher->dispatch(ExpressionVariableEvents::GET, $event); $variables = array_merge($event->getVariables(), [ 'object' => $subject, 'subject' => $subject, ]); if ($subject instanceof Request) { $variables['request'] = $subject; } return $variables; }
php
protected function getVariables(TokenInterface $token, $subject) { $event = new GetExpressionVariablesEvent($token); $this->dispatcher->dispatch(ExpressionVariableEvents::GET, $event); $variables = array_merge($event->getVariables(), [ 'object' => $subject, 'subject' => $subject, ]); if ($subject instanceof Request) { $variables['request'] = $subject; } return $variables; }
[ "protected", "function", "getVariables", "(", "TokenInterface", "$", "token", ",", "$", "subject", ")", "{", "$", "event", "=", "new", "GetExpressionVariablesEvent", "(", "$", "token", ")", ";", "$", "this", "->", "dispatcher", "->", "dispatch", "(", "Expres...
Get the variables. @param TokenInterface $token The token @param mixed $subject The subject to secure @return array
[ "Get", "the", "variables", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Authorization/Voter/ExpressionVoter.php#L100-L115
train
fxpio/fxp-security
Identity/GroupSecurityIdentity.php
GroupSecurityIdentity.fromToken
public static function fromToken(TokenInterface $token) { $user = $token->getUser(); if ($user instanceof GroupableInterface) { $sids = []; $groups = $user->getGroups(); foreach ($groups as $group) { $sids[] = self::fromAccount($group); } return $sids; } throw new InvalidArgumentException('The user class must implement "Fxp\Component\Security\Model\Traits\GroupableInterface"'); }
php
public static function fromToken(TokenInterface $token) { $user = $token->getUser(); if ($user instanceof GroupableInterface) { $sids = []; $groups = $user->getGroups(); foreach ($groups as $group) { $sids[] = self::fromAccount($group); } return $sids; } throw new InvalidArgumentException('The user class must implement "Fxp\Component\Security\Model\Traits\GroupableInterface"'); }
[ "public", "static", "function", "fromToken", "(", "TokenInterface", "$", "token", ")", "{", "$", "user", "=", "$", "token", "->", "getUser", "(", ")", ";", "if", "(", "$", "user", "instanceof", "GroupableInterface", ")", "{", "$", "sids", "=", "[", "]"...
Creates a group security identity from a TokenInterface. @param TokenInterface $token The token @throws InvalidArgumentException When the user class not implements "Fxp\Component\Security\Model\Traits\GroupableInterface" @return self[]
[ "Creates", "a", "group", "security", "identity", "from", "a", "TokenInterface", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Identity/GroupSecurityIdentity.php#L46-L62
train
fxpio/fxp-security
Identity/SubjectIdentity.php
SubjectIdentity.fromObject
public static function fromObject($object) { try { if (!\is_object($object)) { throw new UnexpectedTypeException($object, 'object'); } if ($object instanceof SubjectIdentityInterface) { return $object; } if ($object instanceof SubjectInterface) { return new self(ClassUtils::getClass($object), (string) $object->getSubjectIdentifier(), $object); } if (method_exists($object, 'getId')) { return new self(ClassUtils::getClass($object), (string) $object->getId(), $object); } } catch (InvalidArgumentException $e) { throw new InvalidSubjectIdentityException($e->getMessage(), 0, $e); } throw new InvalidSubjectIdentityException('The object must either implement the SubjectInterface, or have a method named "getId"'); }
php
public static function fromObject($object) { try { if (!\is_object($object)) { throw new UnexpectedTypeException($object, 'object'); } if ($object instanceof SubjectIdentityInterface) { return $object; } if ($object instanceof SubjectInterface) { return new self(ClassUtils::getClass($object), (string) $object->getSubjectIdentifier(), $object); } if (method_exists($object, 'getId')) { return new self(ClassUtils::getClass($object), (string) $object->getId(), $object); } } catch (InvalidArgumentException $e) { throw new InvalidSubjectIdentityException($e->getMessage(), 0, $e); } throw new InvalidSubjectIdentityException('The object must either implement the SubjectInterface, or have a method named "getId"'); }
[ "public", "static", "function", "fromObject", "(", "$", "object", ")", "{", "try", "{", "if", "(", "!", "\\", "is_object", "(", "$", "object", ")", ")", "{", "throw", "new", "UnexpectedTypeException", "(", "$", "object", ",", "'object'", ")", ";", "}",...
Creates a subject identity for the given object. @param object $object The object @throws InvalidSubjectIdentityException @return SubjectIdentityInterface
[ "Creates", "a", "subject", "identity", "for", "the", "given", "object", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Identity/SubjectIdentity.php#L74-L95
train
fxpio/fxp-security
Identity/SubjectIdentity.php
SubjectIdentity.fromClassname
public static function fromClassname($class) { try { if (!class_exists($class)) { throw new InvalidArgumentException(sprintf('The class "%s" does not exist', $class)); } return new self(ClassUtils::getRealClass($class), 'class'); } catch (InvalidArgumentException $e) { throw new InvalidSubjectIdentityException($e->getMessage(), 0, $e); } }
php
public static function fromClassname($class) { try { if (!class_exists($class)) { throw new InvalidArgumentException(sprintf('The class "%s" does not exist', $class)); } return new self(ClassUtils::getRealClass($class), 'class'); } catch (InvalidArgumentException $e) { throw new InvalidSubjectIdentityException($e->getMessage(), 0, $e); } }
[ "public", "static", "function", "fromClassname", "(", "$", "class", ")", "{", "try", "{", "if", "(", "!", "class_exists", "(", "$", "class", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'The class \"%s\" does not exist'", ",...
Creates a subject identity for the given class name. @param string $class The class name @return SubjectIdentity
[ "Creates", "a", "subject", "identity", "for", "the", "given", "class", "name", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Identity/SubjectIdentity.php#L104-L115
train
fxpio/fxp-security
Event/AbstractViewGrantedEvent.php
AbstractViewGrantedEvent.setGranted
public function setGranted($isGranted) { $this->isGranted = (bool) $isGranted; $this->skipAuthorizationChecker(true); return $this; }
php
public function setGranted($isGranted) { $this->isGranted = (bool) $isGranted; $this->skipAuthorizationChecker(true); return $this; }
[ "public", "function", "setGranted", "(", "$", "isGranted", ")", "{", "$", "this", "->", "isGranted", "=", "(", "bool", ")", "$", "isGranted", ";", "$", "this", "->", "skipAuthorizationChecker", "(", "true", ")", ";", "return", "$", "this", ";", "}" ]
Defined if the user has the view access of this object. @param bool $isGranted The granted value @return self
[ "Defined", "if", "the", "user", "has", "the", "view", "access", "of", "this", "object", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Event/AbstractViewGrantedEvent.php#L67-L73
train
fxpio/fxp-security
Event/AbstractViewGrantedEvent.php
AbstractViewGrantedEvent.validateFieldVoteSubject
protected function validateFieldVoteSubject(FieldVote $fieldVote) { $object = $fieldVote->getSubject()->getObject(); if (!\is_object($object)) { throw new UnexpectedTypeException($object, 'object'); } return $object; }
php
protected function validateFieldVoteSubject(FieldVote $fieldVote) { $object = $fieldVote->getSubject()->getObject(); if (!\is_object($object)) { throw new UnexpectedTypeException($object, 'object'); } return $object; }
[ "protected", "function", "validateFieldVoteSubject", "(", "FieldVote", "$", "fieldVote", ")", "{", "$", "object", "=", "$", "fieldVote", "->", "getSubject", "(", ")", "->", "getObject", "(", ")", ";", "if", "(", "!", "\\", "is_object", "(", "$", "object", ...
Validate and return the domain object instance in field vote. @param FieldVote $fieldVote The field vote @return object
[ "Validate", "and", "return", "the", "domain", "object", "instance", "in", "field", "vote", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Event/AbstractViewGrantedEvent.php#L116-L125
train
fxpio/fxp-security
Listener/OrganizationSecurityIdentitySubscriber.php
OrganizationSecurityIdentitySubscriber.addOrganizationSecurityIdentities
public function addOrganizationSecurityIdentities(AddSecurityIdentityEvent $event): void { try { $sids = $event->getSecurityIdentities(); $sids = IdentityUtils::merge( $sids, OrganizationSecurityIdentity::fromToken( $event->getToken(), $this->context, $this->roleHierarchy ) ); $event->setSecurityIdentities($sids); } catch (\InvalidArgumentException $e) { // ignore } }
php
public function addOrganizationSecurityIdentities(AddSecurityIdentityEvent $event): void { try { $sids = $event->getSecurityIdentities(); $sids = IdentityUtils::merge( $sids, OrganizationSecurityIdentity::fromToken( $event->getToken(), $this->context, $this->roleHierarchy ) ); $event->setSecurityIdentities($sids); } catch (\InvalidArgumentException $e) { // ignore } }
[ "public", "function", "addOrganizationSecurityIdentities", "(", "AddSecurityIdentityEvent", "$", "event", ")", ":", "void", "{", "try", "{", "$", "sids", "=", "$", "event", "->", "getSecurityIdentities", "(", ")", ";", "$", "sids", "=", "IdentityUtils", "::", ...
Add organization security identities. @param AddSecurityIdentityEvent $event The event
[ "Add", "organization", "security", "identities", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Listener/OrganizationSecurityIdentitySubscriber.php#L81-L97
train
fxpio/fxp-security
Doctrine/ORM/Listener/ObjectFilterListener.php
ObjectFilterListener.postLoad
public function postLoad(LifecycleEventArgs $args): void { $token = $this->getTokenStorage()->getToken(); if (!$this->getPermissionManager()->isEnabled() || null === $token || $token instanceof ConsoleToken) { return; } $object = $args->getEntity(); $this->getObjectFilter()->filter($object); }
php
public function postLoad(LifecycleEventArgs $args): void { $token = $this->getTokenStorage()->getToken(); if (!$this->getPermissionManager()->isEnabled() || null === $token || $token instanceof ConsoleToken) { return; } $object = $args->getEntity(); $this->getObjectFilter()->filter($object); }
[ "public", "function", "postLoad", "(", "LifecycleEventArgs", "$", "args", ")", ":", "void", "{", "$", "token", "=", "$", "this", "->", "getTokenStorage", "(", ")", "->", "getToken", "(", ")", ";", "if", "(", "!", "$", "this", "->", "getPermissionManager"...
This method is executed after every load that doctrine performs. @param LifecycleEventArgs $args
[ "This", "method", "is", "executed", "after", "every", "load", "that", "doctrine", "performs", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Doctrine/ORM/Listener/ObjectFilterListener.php#L52-L63
train
fxpio/fxp-security
Validator/Constraints/SharingValidator.php
SharingValidator.validateSubject
private function validateSubject(Sharing $constraint, $subjectClass): void { $res = $this->validateClass($constraint, $subjectClass, $constraint->subjectClass); if ($res && !$this->sharingManager->hasSharingVisibility(SubjectIdentity::fromClassname($subjectClass))) { $this->context->buildViolation($constraint->classNotManagedMessage) ->atPath($constraint->subjectClass) ->setParameter('%class_property%', $constraint->subjectClass) ->setParameter('%class%', $subjectClass) ->addViolation() ; } }
php
private function validateSubject(Sharing $constraint, $subjectClass): void { $res = $this->validateClass($constraint, $subjectClass, $constraint->subjectClass); if ($res && !$this->sharingManager->hasSharingVisibility(SubjectIdentity::fromClassname($subjectClass))) { $this->context->buildViolation($constraint->classNotManagedMessage) ->atPath($constraint->subjectClass) ->setParameter('%class_property%', $constraint->subjectClass) ->setParameter('%class%', $subjectClass) ->addViolation() ; } }
[ "private", "function", "validateSubject", "(", "Sharing", "$", "constraint", ",", "$", "subjectClass", ")", ":", "void", "{", "$", "res", "=", "$", "this", "->", "validateClass", "(", "$", "constraint", ",", "$", "subjectClass", ",", "$", "constraint", "->...
Validate the subject. @param Sharing $constraint The sharing constraint @param string $subjectClass The subject class
[ "Validate", "the", "subject", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Validator/Constraints/SharingValidator.php#L73-L85
train
fxpio/fxp-security
Validator/Constraints/SharingValidator.php
SharingValidator.validateIdentity
private function validateIdentity(Sharing $constraint, $identityClass, array $roles, Collection $permissions): void { $res = $this->validateClass($constraint, $identityClass, $constraint->identityClass); if ($res && !$this->sharingManager->hasIdentityConfig($identityClass)) { $res = false; $this->context->buildViolation($constraint->classNotManagedMessage) ->atPath($constraint->identityClass) ->setParameter('%class_property%', $constraint->identityClass) ->setParameter('%class%', $identityClass) ->addViolation() ; } if ($res) { $config = $this->sharingManager->getIdentityConfig($identityClass); $this->validateRoles($constraint, $config, $roles); $this->validatePermissions($constraint, $config, $permissions); } }
php
private function validateIdentity(Sharing $constraint, $identityClass, array $roles, Collection $permissions): void { $res = $this->validateClass($constraint, $identityClass, $constraint->identityClass); if ($res && !$this->sharingManager->hasIdentityConfig($identityClass)) { $res = false; $this->context->buildViolation($constraint->classNotManagedMessage) ->atPath($constraint->identityClass) ->setParameter('%class_property%', $constraint->identityClass) ->setParameter('%class%', $identityClass) ->addViolation() ; } if ($res) { $config = $this->sharingManager->getIdentityConfig($identityClass); $this->validateRoles($constraint, $config, $roles); $this->validatePermissions($constraint, $config, $permissions); } }
[ "private", "function", "validateIdentity", "(", "Sharing", "$", "constraint", ",", "$", "identityClass", ",", "array", "$", "roles", ",", "Collection", "$", "permissions", ")", ":", "void", "{", "$", "res", "=", "$", "this", "->", "validateClass", "(", "$"...
Validate the identity. @param Sharing $constraint The sharing constraint @param string $identityClass The identity class @param string[] $roles The roles @param Collection $permissions The permissions
[ "Validate", "the", "identity", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Validator/Constraints/SharingValidator.php#L95-L114
train
fxpio/fxp-security
Validator/Constraints/SharingValidator.php
SharingValidator.validateRoles
private function validateRoles( Sharing $constraint, SharingIdentityConfigInterface $config, array $roles ): void { if (!empty($roles) && !$config->isPermissible()) { $this->context->buildViolation($constraint->identityNotRoleableMessage) ->atPath($constraint->roles) ->setParameter('%class_property%', $constraint->identityClass) ->setParameter('%class%', $config->getType()) ->addViolation() ; } }
php
private function validateRoles( Sharing $constraint, SharingIdentityConfigInterface $config, array $roles ): void { if (!empty($roles) && !$config->isPermissible()) { $this->context->buildViolation($constraint->identityNotRoleableMessage) ->atPath($constraint->roles) ->setParameter('%class_property%', $constraint->identityClass) ->setParameter('%class%', $config->getType()) ->addViolation() ; } }
[ "private", "function", "validateRoles", "(", "Sharing", "$", "constraint", ",", "SharingIdentityConfigInterface", "$", "config", ",", "array", "$", "roles", ")", ":", "void", "{", "if", "(", "!", "empty", "(", "$", "roles", ")", "&&", "!", "$", "config", ...
Validate the roles field. @param Sharing $constraint The sharing constraint @param SharingIdentityConfigInterface $config The sharing identity config @param string[] $roles The roles
[ "Validate", "the", "roles", "field", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Validator/Constraints/SharingValidator.php#L123-L136
train
fxpio/fxp-security
Validator/Constraints/SharingValidator.php
SharingValidator.validatePermissions
private function validatePermissions( Sharing $constraint, SharingIdentityConfigInterface $config, Collection $permissions ): void { if ($permissions->count() > 0 && !$config->isPermissible()) { $this->context->buildViolation($constraint->identityNotPermissibleMessage) ->atPath($constraint->permissions) ->setParameter('%class_property%', $constraint->identityClass) ->setParameter('%class%', $config->getType()) ->addViolation() ; } }
php
private function validatePermissions( Sharing $constraint, SharingIdentityConfigInterface $config, Collection $permissions ): void { if ($permissions->count() > 0 && !$config->isPermissible()) { $this->context->buildViolation($constraint->identityNotPermissibleMessage) ->atPath($constraint->permissions) ->setParameter('%class_property%', $constraint->identityClass) ->setParameter('%class%', $config->getType()) ->addViolation() ; } }
[ "private", "function", "validatePermissions", "(", "Sharing", "$", "constraint", ",", "SharingIdentityConfigInterface", "$", "config", ",", "Collection", "$", "permissions", ")", ":", "void", "{", "if", "(", "$", "permissions", "->", "count", "(", ")", ">", "0...
Validate the permissions field. @param Sharing $constraint The sharing constraint @param SharingIdentityConfigInterface $config The sharing identity config @param Collection $permissions The permissions
[ "Validate", "the", "permissions", "field", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Validator/Constraints/SharingValidator.php#L145-L158
train
fxpio/fxp-security
ObjectFilter/ObjectFilter.php
ObjectFilter.doFilter
protected function doFilter($object): void { $clearAll = false; $id = spl_object_hash($object); array_splice($this->toFilter, array_search($id, $this->toFilter, true), 1); if (!$this->isViewGranted($object)) { $clearAll = true; } $ref = new \ReflectionClass($object); foreach ($ref->getProperties() as $property) { $property->setAccessible(true); $fieldVote = new FieldVote($object, $property->getName()); $value = $property->getValue($object); if ($this->isFilterViewGranted($fieldVote, $value, $clearAll)) { $value = $this->ofe->filterValue($value); $property->setValue($object, $value); } } }
php
protected function doFilter($object): void { $clearAll = false; $id = spl_object_hash($object); array_splice($this->toFilter, array_search($id, $this->toFilter, true), 1); if (!$this->isViewGranted($object)) { $clearAll = true; } $ref = new \ReflectionClass($object); foreach ($ref->getProperties() as $property) { $property->setAccessible(true); $fieldVote = new FieldVote($object, $property->getName()); $value = $property->getValue($object); if ($this->isFilterViewGranted($fieldVote, $value, $clearAll)) { $value = $this->ofe->filterValue($value); $property->setValue($object, $value); } } }
[ "protected", "function", "doFilter", "(", "$", "object", ")", ":", "void", "{", "$", "clearAll", "=", "false", ";", "$", "id", "=", "spl_object_hash", "(", "$", "object", ")", ";", "array_splice", "(", "$", "this", "->", "toFilter", ",", "array_search", ...
Executes the filtering. @param object $object
[ "Executes", "the", "filtering", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/ObjectFilter/ObjectFilter.php#L205-L227
train
fxpio/fxp-security
ObjectFilter/ObjectFilter.php
ObjectFilter.doRestore
protected function doRestore($object): void { $changeSet = $this->uow->getObjectChangeSet($object); $ref = new \ReflectionClass($object); foreach ($changeSet as $field => $values) { $fv = new FieldVote($object, $field); if ($this->isRestoreViewGranted($fv, $values)) { $property = $ref->getProperty($field); $property->setAccessible(true); $property->setValue($object, $values['old']); } } }
php
protected function doRestore($object): void { $changeSet = $this->uow->getObjectChangeSet($object); $ref = new \ReflectionClass($object); foreach ($changeSet as $field => $values) { $fv = new FieldVote($object, $field); if ($this->isRestoreViewGranted($fv, $values)) { $property = $ref->getProperty($field); $property->setAccessible(true); $property->setValue($object, $values['old']); } } }
[ "protected", "function", "doRestore", "(", "$", "object", ")", ":", "void", "{", "$", "changeSet", "=", "$", "this", "->", "uow", "->", "getObjectChangeSet", "(", "$", "object", ")", ";", "$", "ref", "=", "new", "\\", "ReflectionClass", "(", "$", "obje...
Executes the restoring. @param object $object
[ "Executes", "the", "restoring", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/ObjectFilter/ObjectFilter.php#L234-L248
train
fxpio/fxp-security
ObjectFilter/ObjectFilter.php
ObjectFilter.isFilterViewGranted
protected function isFilterViewGranted(FieldVote $fieldVote, $value, $clearAll) { return null !== $value && !$this->isIdentifier($fieldVote, $value) && ($clearAll || !$this->isViewGranted($fieldVote)); }
php
protected function isFilterViewGranted(FieldVote $fieldVote, $value, $clearAll) { return null !== $value && !$this->isIdentifier($fieldVote, $value) && ($clearAll || !$this->isViewGranted($fieldVote)); }
[ "protected", "function", "isFilterViewGranted", "(", "FieldVote", "$", "fieldVote", ",", "$", "value", ",", "$", "clearAll", ")", "{", "return", "null", "!==", "$", "value", "&&", "!", "$", "this", "->", "isIdentifier", "(", "$", "fieldVote", ",", "$", "...
Check if the field value must be filtered. @param FieldVote $fieldVote The field vote @param mixed $value The value @param bool $clearAll Check if all fields must be filtered @return bool
[ "Check", "if", "the", "field", "value", "must", "be", "filtered", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/ObjectFilter/ObjectFilter.php#L259-L264
train
fxpio/fxp-security
ObjectFilter/ObjectFilter.php
ObjectFilter.isRestoreViewGranted
protected function isRestoreViewGranted(FieldVote $fieldVote, array $values) { $event = new RestoreViewGrantedEvent($fieldVote, $values['old'], $values['new']); $this->dispatcher->dispatch(ObjectFilterEvents::RESTORE_VIEW_GRANTED, $event); if ($event->isSkipAuthorizationChecker()) { return !$event->isGranted(); } return !$this->ac->isGranted('perm_read', $fieldVote) || !$this->ac->isGranted('perm_edit', $fieldVote); }
php
protected function isRestoreViewGranted(FieldVote $fieldVote, array $values) { $event = new RestoreViewGrantedEvent($fieldVote, $values['old'], $values['new']); $this->dispatcher->dispatch(ObjectFilterEvents::RESTORE_VIEW_GRANTED, $event); if ($event->isSkipAuthorizationChecker()) { return !$event->isGranted(); } return !$this->ac->isGranted('perm_read', $fieldVote) || !$this->ac->isGranted('perm_edit', $fieldVote); }
[ "protected", "function", "isRestoreViewGranted", "(", "FieldVote", "$", "fieldVote", ",", "array", "$", "values", ")", "{", "$", "event", "=", "new", "RestoreViewGrantedEvent", "(", "$", "fieldVote", ",", "$", "values", "[", "'old'", "]", ",", "$", "values",...
Check if the field value must be restored. @param FieldVote $fieldVote The field vote @param array $values The map of old and new values @return bool
[ "Check", "if", "the", "field", "value", "must", "be", "restored", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/ObjectFilter/ObjectFilter.php#L274-L285
train
fxpio/fxp-security
ObjectFilter/ObjectFilter.php
ObjectFilter.isViewGranted
protected function isViewGranted($object) { if ($object instanceof FieldVote) { $eventName = ObjectFilterEvents::OBJECT_FIELD_VIEW_GRANTED; $event = new ObjectFieldViewGrantedEvent($object); $permission = 'perm_read'; } else { $eventName = ObjectFilterEvents::OBJECT_VIEW_GRANTED; $event = new ObjectViewGrantedEvent($object); $permission = 'perm_view'; } $this->dispatcher->dispatch($eventName, $event); if ($event->isSkipAuthorizationChecker()) { return $event->isGranted(); } return $this->ac->isGranted($permission, $object); }
php
protected function isViewGranted($object) { if ($object instanceof FieldVote) { $eventName = ObjectFilterEvents::OBJECT_FIELD_VIEW_GRANTED; $event = new ObjectFieldViewGrantedEvent($object); $permission = 'perm_read'; } else { $eventName = ObjectFilterEvents::OBJECT_VIEW_GRANTED; $event = new ObjectViewGrantedEvent($object); $permission = 'perm_view'; } $this->dispatcher->dispatch($eventName, $event); if ($event->isSkipAuthorizationChecker()) { return $event->isGranted(); } return $this->ac->isGranted($permission, $object); }
[ "protected", "function", "isViewGranted", "(", "$", "object", ")", "{", "if", "(", "$", "object", "instanceof", "FieldVote", ")", "{", "$", "eventName", "=", "ObjectFilterEvents", "::", "OBJECT_FIELD_VIEW_GRANTED", ";", "$", "event", "=", "new", "ObjectFieldView...
Check if the object or object field can be seen. @param FieldVote|object $object The object or field vote @return bool
[ "Check", "if", "the", "object", "or", "object", "field", "can", "be", "seen", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/ObjectFilter/ObjectFilter.php#L294-L313
train
fxpio/fxp-security
ObjectFilter/ObjectFilter.php
ObjectFilter.isIdentifier
protected function isIdentifier(FieldVote $fieldVote, $value) { return (\is_int($value) || \is_string($value)) && (string) $value === $fieldVote->getSubject()->getIdentifier() && \in_array($fieldVote->getField(), ['id', 'subjectIdentifier'], true); }
php
protected function isIdentifier(FieldVote $fieldVote, $value) { return (\is_int($value) || \is_string($value)) && (string) $value === $fieldVote->getSubject()->getIdentifier() && \in_array($fieldVote->getField(), ['id', 'subjectIdentifier'], true); }
[ "protected", "function", "isIdentifier", "(", "FieldVote", "$", "fieldVote", ",", "$", "value", ")", "{", "return", "(", "\\", "is_int", "(", "$", "value", ")", "||", "\\", "is_string", "(", "$", "value", ")", ")", "&&", "(", "string", ")", "$", "val...
Check if the field is an identifier. @param FieldVote $fieldVote The field vote @param mixed $value The value @return bool
[ "Check", "if", "the", "field", "is", "an", "identifier", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/ObjectFilter/ObjectFilter.php#L323-L328
train
fxpio/fxp-security
ObjectFilter/ObjectFilter.php
ObjectFilter.isExcludedClass
protected function isExcludedClass($object) { foreach ($this->excludedClasses as $excludedClass) { if ($object instanceof $excludedClass) { return true; } } return false; }
php
protected function isExcludedClass($object) { foreach ($this->excludedClasses as $excludedClass) { if ($object instanceof $excludedClass) { return true; } } return false; }
[ "protected", "function", "isExcludedClass", "(", "$", "object", ")", "{", "foreach", "(", "$", "this", "->", "excludedClasses", "as", "$", "excludedClass", ")", "{", "if", "(", "$", "object", "instanceof", "$", "excludedClass", ")", "{", "return", "true", ...
Check if the object is an excluded class. @param object $object The object @return bool
[ "Check", "if", "the", "object", "is", "an", "excluded", "class", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/ObjectFilter/ObjectFilter.php#L337-L346
train
fxpio/fxp-security
Organizational/OrganizationalUtil.php
OrganizationalUtil.format
public static function format($name) { if (false !== ($pos = strrpos($name, '__'))) { $name = substr($name, 0, $pos); } return $name; }
php
public static function format($name) { if (false !== ($pos = strrpos($name, '__'))) { $name = substr($name, 0, $pos); } return $name; }
[ "public", "static", "function", "format", "(", "$", "name", ")", "{", "if", "(", "false", "!==", "(", "$", "pos", "=", "strrpos", "(", "$", "name", ",", "'__'", ")", ")", ")", "{", "$", "name", "=", "substr", "(", "$", "name", ",", "0", ",", ...
Format the organizational name without suffix. @param string $name The name @return string
[ "Format", "the", "organizational", "name", "without", "suffix", "." ]
f04be8baf1ea16aa91074721eb82a7689e248e96
https://github.com/fxpio/fxp-security/blob/f04be8baf1ea16aa91074721eb82a7689e248e96/Organizational/OrganizationalUtil.php#L64-L71
train
grrr-amsterdam/garp-functional
types/Sum.php
Sum.concat
public function concat(Semigroup $that): Semigroup { if (!$that instanceof self) { throw new \LogicException('Semigroup cannot concatenate two distinct types.'); } return new Sum($this->value + $that->value); }
php
public function concat(Semigroup $that): Semigroup { if (!$that instanceof self) { throw new \LogicException('Semigroup cannot concatenate two distinct types.'); } return new Sum($this->value + $that->value); }
[ "public", "function", "concat", "(", "Semigroup", "$", "that", ")", ":", "Semigroup", "{", "if", "(", "!", "$", "that", "instanceof", "self", ")", "{", "throw", "new", "\\", "LogicException", "(", "'Semigroup cannot concatenate two distinct types.'", ")", ";", ...
Concatenate two semigroups. @param Semigroup $that @return Semigroup
[ "Concatenate", "two", "semigroups", "." ]
f5a56dd195ae8aac869c073ea935d6ff17e878ad
https://github.com/grrr-amsterdam/garp-functional/blob/f5a56dd195ae8aac869c073ea935d6ff17e878ad/types/Sum.php#L36-L41
train