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
thecodingmachine/mouf
src/Mouf/Reflection/MoufReflectionProxy.php
MoufReflectionProxy.getConfigConstants
public static function getConfigConstants($selfEdit) { $url = MoufReflectionProxy::getLocalUrlToProject()."src/direct/get_defined_constants.php?selfedit=".(($selfEdit)?"true":"false"); $response = self::performRequest($url); $obj = @unserialize($response); if ($obj === false) { throw new Exception("Unable to unserialize message:\n".$response."\n<br/>URL in error: <a href='".plainstring_to_htmlprotected($url)."'>".plainstring_to_htmlprotected($url)."</a>"); } return $obj; }
php
public static function getConfigConstants($selfEdit) { $url = MoufReflectionProxy::getLocalUrlToProject()."src/direct/get_defined_constants.php?selfedit=".(($selfEdit)?"true":"false"); $response = self::performRequest($url); $obj = @unserialize($response); if ($obj === false) { throw new Exception("Unable to unserialize message:\n".$response."\n<br/>URL in error: <a href='".plainstring_to_htmlprotected($url)."'>".plainstring_to_htmlprotected($url)."</a>"); } return $obj; }
[ "public", "static", "function", "getConfigConstants", "(", "$", "selfEdit", ")", "{", "$", "url", "=", "MoufReflectionProxy", "::", "getLocalUrlToProject", "(", ")", ".", "\"src/direct/get_defined_constants.php?selfedit=\"", ".", "(", "(", "$", "selfEdit", ")", "?",...
Returns the array of all constants defined in the config.php file at the root of the project. @return array
[ "Returns", "the", "array", "of", "all", "constants", "defined", "in", "the", "config", ".", "php", "file", "at", "the", "root", "of", "the", "project", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/MoufReflectionProxy.php#L114-L127
train
thecodingmachine/mouf
src/Mouf/Reflection/MoufReflectionProxy.php
MoufReflectionProxy.analyzeIncludes2
public static function analyzeIncludes2($selfEdit, $forbiddenClasses) { $url = MoufReflectionProxy::getLocalUrlToProject()."src/direct/analyze_includes_2.php"; /*foreach ($forbiddenClasses as $forbiddenClass) { $url .= "&forbiddenClasses[]=".$forbiddenClass; }*/ $response = self::performRequest($url, array("selfedit"=>json_encode($selfEdit), "classMap"=>json_encode($forbiddenClasses))); // Let's strip the invalid parts: /*$arr = explode("\nX4EVDX4SEVX548DSVDXCDSF489\n", $response); if (count($arr) < 2) { // No delimiter: there has been a crash. return array("errorType"=>"crash", "errorMsg"=>$response); } $msg = $arr[count($arr)-1]; $obj = unserialize($msg); if ($obj === false) { throw new Exception("Unable to unserialize message:\n".$response."\n<br/>URL in error: <a href='".plainstring_to_htmlprotected($url)."'>".plainstring_to_htmlprotected($url)."</a>"); } return $obj;*/ return $response; }
php
public static function analyzeIncludes2($selfEdit, $forbiddenClasses) { $url = MoufReflectionProxy::getLocalUrlToProject()."src/direct/analyze_includes_2.php"; /*foreach ($forbiddenClasses as $forbiddenClass) { $url .= "&forbiddenClasses[]=".$forbiddenClass; }*/ $response = self::performRequest($url, array("selfedit"=>json_encode($selfEdit), "classMap"=>json_encode($forbiddenClasses))); // Let's strip the invalid parts: /*$arr = explode("\nX4EVDX4SEVX548DSVDXCDSF489\n", $response); if (count($arr) < 2) { // No delimiter: there has been a crash. return array("errorType"=>"crash", "errorMsg"=>$response); } $msg = $arr[count($arr)-1]; $obj = unserialize($msg); if ($obj === false) { throw new Exception("Unable to unserialize message:\n".$response."\n<br/>URL in error: <a href='".plainstring_to_htmlprotected($url)."'>".plainstring_to_htmlprotected($url)."</a>"); } return $obj;*/ return $response; }
[ "public", "static", "function", "analyzeIncludes2", "(", "$", "selfEdit", ",", "$", "forbiddenClasses", ")", "{", "$", "url", "=", "MoufReflectionProxy", "::", "getLocalUrlToProject", "(", ")", ".", "\"src/direct/analyze_includes_2.php\"", ";", "/*foreach ($forbiddenCla...
Analyzes the include files. @param string $selfEdit @throws Exception
[ "Analyzes", "the", "include", "files", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/MoufReflectionProxy.php#L167-L191
train
thecodingmachine/mouf
src/Mouf/Reflection/MoufReflectionProxy.php
MoufReflectionProxy.getReturnTypeFromCode
public static function getReturnTypeFromCode($code, $selfEdit) { $url = MoufReflectionProxy::getLocalUrlToProject()."src/direct/return_type_from_code.php"; $response = self::performRequest($url, [ "selfedit"=>($selfEdit)?"true":"false", "code" => $code ]); $obj = @unserialize($response); if ($obj === false) { throw new Exception($response); } return $obj["data"]["class"]; }
php
public static function getReturnTypeFromCode($code, $selfEdit) { $url = MoufReflectionProxy::getLocalUrlToProject()."src/direct/return_type_from_code.php"; $response = self::performRequest($url, [ "selfedit"=>($selfEdit)?"true":"false", "code" => $code ]); $obj = @unserialize($response); if ($obj === false) { throw new Exception($response); } return $obj["data"]["class"]; }
[ "public", "static", "function", "getReturnTypeFromCode", "(", "$", "code", ",", "$", "selfEdit", ")", "{", "$", "url", "=", "MoufReflectionProxy", "::", "getLocalUrlToProject", "(", ")", ".", "\"src/direct/return_type_from_code.php\"", ";", "$", "response", "=", "...
Returns the "return" fully qualified class name from the code passed in parameter. @param string $code @param bool $selfEdit @throws Exception @return string
[ "Returns", "the", "return", "fully", "qualified", "class", "name", "from", "the", "code", "passed", "in", "parameter", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/MoufReflectionProxy.php#L224-L241
train
thecodingmachine/mouf
src/Mouf/Reflection/MoufReflectionProxy.php
MoufReflectionProxy.performRequest
public static function performRequest($url, $post = array()) { // preparation de l'envoi $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); if($post) { curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post, '', '&')); } else { curl_setopt($ch, CURLOPT_POST, false); } if (isset($_SERVER['HTTPS'])) { curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); } curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); //Fixes the HTTP/1.1 417 Expectation Failed Bug // Let's forward all cookies so the session in preserved. // Problem: because the session file is locked, we cannot do that without closing the session first session_write_close(); $cookieArr = array(); foreach ($_COOKIE as $key=>$value) { $cookieArr[] = $key."=".urlencode($value); } $cookieStr = implode("; ", $cookieArr); curl_setopt($ch, CURLOPT_COOKIE, $cookieStr); $response = curl_exec($ch ); // And let's reopen the session... session_start(); if( curl_error($ch) ) { throw new MoufException("An error occurred: ".curl_error($ch)); } curl_close( $ch ); return $response; }
php
public static function performRequest($url, $post = array()) { // preparation de l'envoi $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); if($post) { curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post, '', '&')); } else { curl_setopt($ch, CURLOPT_POST, false); } if (isset($_SERVER['HTTPS'])) { curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); } curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); //Fixes the HTTP/1.1 417 Expectation Failed Bug // Let's forward all cookies so the session in preserved. // Problem: because the session file is locked, we cannot do that without closing the session first session_write_close(); $cookieArr = array(); foreach ($_COOKIE as $key=>$value) { $cookieArr[] = $key."=".urlencode($value); } $cookieStr = implode("; ", $cookieArr); curl_setopt($ch, CURLOPT_COOKIE, $cookieStr); $response = curl_exec($ch ); // And let's reopen the session... session_start(); if( curl_error($ch) ) { throw new MoufException("An error occurred: ".curl_error($ch)); } curl_close( $ch ); return $response; }
[ "public", "static", "function", "performRequest", "(", "$", "url", ",", "$", "post", "=", "array", "(", ")", ")", "{", "// preparation de l'envoi\r", "$", "ch", "=", "curl_init", "(", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_URL", ",", "$",...
Performs a request using CURL using GET or POST methods and returns the result. @param string $url @param array<string, string> $post POST parameters @throws \Exception
[ "Performs", "a", "request", "using", "CURL", "using", "GET", "or", "POST", "methods", "and", "returns", "the", "result", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/MoufReflectionProxy.php#L271-L313
train
thecodingmachine/mouf
src/Mouf/Reflection/MoufReflectionProxy.php
MoufReflectionProxy.performRequestWithoutSession
public static function performRequestWithoutSession($url, $post = array()) { // preparation de l'envoi $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); if($post) { curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post)); } else { curl_setopt($ch, CURLOPT_POST, false); } if (isset($_SERVER['HTTPS'])) { curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); } curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); //Fixes the HTTP/1.1 417 Expectation Failed Bug $response = curl_exec($ch ); if( curl_error($ch) ) { throw new \Exception("An error occured: ".curl_error($ch)); } curl_close( $ch ); return $response; }
php
public static function performRequestWithoutSession($url, $post = array()) { // preparation de l'envoi $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); if($post) { curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post)); } else { curl_setopt($ch, CURLOPT_POST, false); } if (isset($_SERVER['HTTPS'])) { curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); } curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); //Fixes the HTTP/1.1 417 Expectation Failed Bug $response = curl_exec($ch ); if( curl_error($ch) ) { throw new \Exception("An error occured: ".curl_error($ch)); } curl_close( $ch ); return $response; }
[ "public", "static", "function", "performRequestWithoutSession", "(", "$", "url", ",", "$", "post", "=", "array", "(", ")", ")", "{", "// preparation de l'envoi\r", "$", "ch", "=", "curl_init", "(", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_URL",...
Performs a curl request, same as performRequest, but without using the session nore the cookies... @param string $url @param array<string, mixed> $post @throws \Exception @return mixed
[ "Performs", "a", "curl", "request", "same", "as", "performRequest", "but", "without", "using", "the", "session", "nore", "the", "cookies", "..." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/MoufReflectionProxy.php#L322-L351
train
thecodingmachine/mouf
src-dev/Mouf/Controllers/Composer/InstalledPackagesController.php
InstalledPackagesController.search
public function search($text) { $composerService = new ComposerService(false, true); ChunckedUtils::init(); $msg = "<script>window.parent.Composer.consoleOutput('Composer is searching...<br/>')</script>"; ChunckedUtils::writeChunk($msg); $msg = "<script>window.parent.Composer.setSearchStatus(true)</script>"; ChunckedUtils::writeChunk($msg); $composerService->searchPackages($text, $this); $msg = "<script>window.parent.Composer.setSearchStatus(false)</script>"; ChunckedUtils::writeChunk($msg); ChunckedUtils::close(); }
php
public function search($text) { $composerService = new ComposerService(false, true); ChunckedUtils::init(); $msg = "<script>window.parent.Composer.consoleOutput('Composer is searching...<br/>')</script>"; ChunckedUtils::writeChunk($msg); $msg = "<script>window.parent.Composer.setSearchStatus(true)</script>"; ChunckedUtils::writeChunk($msg); $composerService->searchPackages($text, $this); $msg = "<script>window.parent.Composer.setSearchStatus(false)</script>"; ChunckedUtils::writeChunk($msg); ChunckedUtils::close(); }
[ "public", "function", "search", "(", "$", "text", ")", "{", "$", "composerService", "=", "new", "ComposerService", "(", "false", ",", "true", ")", ";", "ChunckedUtils", "::", "init", "(", ")", ";", "$", "msg", "=", "\"<script>window.parent.Composer.consoleOutp...
Searches the packages and returns a list of matching packages. @URL composer/search @param string $text
[ "Searches", "the", "packages", "and", "returns", "a", "list", "of", "matching", "packages", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/Composer/InstalledPackagesController.php#L98-L115
train
thecodingmachine/mouf
src-dev/Mouf/Controllers/Composer/InstalledPackagesController.php
InstalledPackagesController.doInstall
public function doInstall($name, $version, $selfedit = "false") { $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } $composerService = new ComposerService($this->selfedit == "true", true); ChunckedUtils::init(); $msg = "<script>window.parent.Composer.consoleOutput('Starting installation process...<br/>')</script>"; ChunckedUtils::writeChunk($msg); $composerService->install($name, $version); ChunckedUtils::close(); }
php
public function doInstall($name, $version, $selfedit = "false") { $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } $composerService = new ComposerService($this->selfedit == "true", true); ChunckedUtils::init(); $msg = "<script>window.parent.Composer.consoleOutput('Starting installation process...<br/>')</script>"; ChunckedUtils::writeChunk($msg); $composerService->install($name, $version); ChunckedUtils::close(); }
[ "public", "function", "doInstall", "(", "$", "name", ",", "$", "version", ",", "$", "selfedit", "=", "\"false\"", ")", "{", "$", "this", "->", "selfedit", "=", "$", "selfedit", ";", "if", "(", "$", "selfedit", "==", "\"true\"", ")", "{", "$", "this",...
Actually performs the package installation. @URL composer/doInstall @param string $name @param string $version @param string $selfedit
[ "Actually", "performs", "the", "package", "installation", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/Composer/InstalledPackagesController.php#L198-L218
train
thecodingmachine/mouf
src-dev/Mouf/Controllers/Composer/InstalledPackagesController.php
InstalledPackagesController.uninstall
public function uninstall($name, $selfedit = "false") { $this->selfedit = $selfedit; $this->name = $name; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } $this->contentBlock->addFile(ROOT_PATH."src-dev/views/composer/uninstall.php", $this); $this->template->toHtml(); }
php
public function uninstall($name, $selfedit = "false") { $this->selfedit = $selfedit; $this->name = $name; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } $this->contentBlock->addFile(ROOT_PATH."src-dev/views/composer/uninstall.php", $this); $this->template->toHtml(); }
[ "public", "function", "uninstall", "(", "$", "name", ",", "$", "selfedit", "=", "\"false\"", ")", "{", "$", "this", "->", "selfedit", "=", "$", "selfedit", ";", "$", "this", "->", "name", "=", "$", "name", ";", "if", "(", "$", "selfedit", "==", "\"...
Triggers the removal of the composer package passed in parameter. This will actually display a screen with an iframe that will do the real uninstall process. @Post @URL composer/uninstall @param string $name @param string $selfedit
[ "Triggers", "the", "removal", "of", "the", "composer", "package", "passed", "in", "parameter", ".", "This", "will", "actually", "display", "a", "screen", "with", "an", "iframe", "that", "will", "do", "the", "real", "uninstall", "process", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/Composer/InstalledPackagesController.php#L229-L241
train
thecodingmachine/mouf
src-dev/Mouf/Controllers/Composer/InstalledPackagesController.php
InstalledPackagesController.doUninstall
public function doUninstall($name, $selfedit = "false") { $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } $composerService = new ComposerService($this->selfedit == "true", true); ChunckedUtils::init(); $msg = "<script>window.parent.Composer.consoleOutput('Starting uninstall process...<br/>')</script>"; ChunckedUtils::writeChunk($msg); $composerService->uninstall($name); ChunckedUtils::close(); }
php
public function doUninstall($name, $selfedit = "false") { $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } $composerService = new ComposerService($this->selfedit == "true", true); ChunckedUtils::init(); $msg = "<script>window.parent.Composer.consoleOutput('Starting uninstall process...<br/>')</script>"; ChunckedUtils::writeChunk($msg); $composerService->uninstall($name); ChunckedUtils::close(); }
[ "public", "function", "doUninstall", "(", "$", "name", ",", "$", "selfedit", "=", "\"false\"", ")", "{", "$", "this", "->", "selfedit", "=", "$", "selfedit", ";", "if", "(", "$", "selfedit", "==", "\"true\"", ")", "{", "$", "this", "->", "moufManager",...
Actually performs the package removal. @URL composer/doUninstall @param string $name @param string $selfedit
[ "Actually", "performs", "the", "package", "removal", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/Composer/InstalledPackagesController.php#L250-L270
train
thecodingmachine/mouf
src/Mouf/Reflection/MoufXmlReflectionParameter.php
MoufXmlReflectionParameter.getDeclaringFunction
public function getDeclaringFunction() { if (null === $this->refRoutine) { if (is_array($this->routineName) === true) { $this->refRoutine = new MoufReflectionMethod($this->routineName[0], $this->routineName[1]); } } return $this->refRoutine; }
php
public function getDeclaringFunction() { if (null === $this->refRoutine) { if (is_array($this->routineName) === true) { $this->refRoutine = new MoufReflectionMethod($this->routineName[0], $this->routineName[1]); } } return $this->refRoutine; }
[ "public", "function", "getDeclaringFunction", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "refRoutine", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "routineName", ")", "===", "true", ")", "{", "$", "this", "->", "refRoutine...
helper method to return the reflection routine defining this parameter @return MoufReflectionMethod
[ "helper", "method", "to", "return", "the", "reflection", "routine", "defining", "this", "parameter" ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/MoufXmlReflectionParameter.php#L81-L90
train
thecodingmachine/mouf
src/Mouf/Reflection/MoufReflectionClass.php
MoufReflectionClass.getMethodsByPattern
public function getMethodsByPattern($regex) { $methods = parent::getMethods(); $moufMethods = array(); foreach ($methods as $method) { if (preg_match("/$regex/", $method->getName())) { $moufMethods[$method->getName()] = new MoufReflectionMethod($this, $method->getName()); } } return $moufMethods; }
php
public function getMethodsByPattern($regex) { $methods = parent::getMethods(); $moufMethods = array(); foreach ($methods as $method) { if (preg_match("/$regex/", $method->getName())) { $moufMethods[$method->getName()] = new MoufReflectionMethod($this, $method->getName()); } } return $moufMethods; }
[ "public", "function", "getMethodsByPattern", "(", "$", "regex", ")", "{", "$", "methods", "=", "parent", "::", "getMethods", "(", ")", ";", "$", "moufMethods", "=", "array", "(", ")", ";", "foreach", "(", "$", "methods", "as", "$", "method", ")", "{", ...
returns a list of all methods matching a given regex @param string $regex the regex to macth @return array<MoufReflectionMethod>
[ "returns", "a", "list", "of", "all", "methods", "matching", "a", "given", "regex" ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/MoufReflectionClass.php#L177-L188
train
thecodingmachine/mouf
src/Mouf/Reflection/MoufReflectionClass.php
MoufReflectionClass.getExtension
public function getExtension() { $extensionName = $this->getExtensionName(); if (null === $extensionName || false === $extensionName) { return null; } $moufRefExtension = new MoufReflectionExtension($extensionName); return $moufRefExtension; }
php
public function getExtension() { $extensionName = $this->getExtensionName(); if (null === $extensionName || false === $extensionName) { return null; } $moufRefExtension = new MoufReflectionExtension($extensionName); return $moufRefExtension; }
[ "public", "function", "getExtension", "(", ")", "{", "$", "extensionName", "=", "$", "this", "->", "getExtensionName", "(", ")", ";", "if", "(", "null", "===", "$", "extensionName", "||", "false", "===", "$", "extensionName", ")", "{", "return", "null", ...
returns the extension to where this class belongs too @return MoufReflectionExtension
[ "returns", "the", "extension", "to", "where", "this", "class", "belongs", "too" ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/MoufReflectionClass.php#L327-L336
train
thecodingmachine/mouf
src/Mouf/Reflection/MoufReflectionClass.php
MoufReflectionClass.getInjectablePropertiesByConstructor
public function getInjectablePropertiesByConstructor() { if ($this->injectablePropertiesByConstructor === null) { $moufProperties = array(); $constructor = $this->getConstructor(); if ($constructor != null) { foreach($constructor->getParameters() as $parameter) { $propertyDescriptor = new MoufPropertyDescriptor($parameter); $moufProperties[$propertyDescriptor->getName()] = $propertyDescriptor; } } $this->injectablePropertiesByConstructor = $moufProperties; } return $this->injectablePropertiesByConstructor; }
php
public function getInjectablePropertiesByConstructor() { if ($this->injectablePropertiesByConstructor === null) { $moufProperties = array(); $constructor = $this->getConstructor(); if ($constructor != null) { foreach($constructor->getParameters() as $parameter) { $propertyDescriptor = new MoufPropertyDescriptor($parameter); $moufProperties[$propertyDescriptor->getName()] = $propertyDescriptor; } } $this->injectablePropertiesByConstructor = $moufProperties; } return $this->injectablePropertiesByConstructor; }
[ "public", "function", "getInjectablePropertiesByConstructor", "(", ")", "{", "if", "(", "$", "this", "->", "injectablePropertiesByConstructor", "===", "null", ")", "{", "$", "moufProperties", "=", "array", "(", ")", ";", "$", "constructor", "=", "$", "this", "...
Returns the list of MoufPropertyDescriptor that can be injected via the constructor. @return MoufPropertyDescriptor[] An associative array. The key is the name of the argument.
[ "Returns", "the", "list", "of", "MoufPropertyDescriptor", "that", "can", "be", "injected", "via", "the", "constructor", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/MoufReflectionClass.php#L387-L400
train
thecodingmachine/mouf
src/Mouf/Reflection/MoufReflectionClass.php
MoufReflectionClass.getInjectablePropertiesByPublicProperty
public function getInjectablePropertiesByPublicProperty() { if ($this->injectablePropertiesByPublicProperty === null) { $moufProperties = array(); foreach($this->getProperties() as $attribute) { /* @var $attribute MoufXmlReflectionProperty */ //if ($attribute->hasAnnotation("Property")) { if ($attribute->isPublic() && !$attribute->isStatic()) { // We might want to catch it and to display it properly $propertyDescriptor = new MoufPropertyDescriptor($attribute); $moufProperties[$attribute->getName()] = $propertyDescriptor; } //} } $this->injectablePropertiesByPublicProperty = $moufProperties; } return $this->injectablePropertiesByPublicProperty; }
php
public function getInjectablePropertiesByPublicProperty() { if ($this->injectablePropertiesByPublicProperty === null) { $moufProperties = array(); foreach($this->getProperties() as $attribute) { /* @var $attribute MoufXmlReflectionProperty */ //if ($attribute->hasAnnotation("Property")) { if ($attribute->isPublic() && !$attribute->isStatic()) { // We might want to catch it and to display it properly $propertyDescriptor = new MoufPropertyDescriptor($attribute); $moufProperties[$attribute->getName()] = $propertyDescriptor; } //} } $this->injectablePropertiesByPublicProperty = $moufProperties; } return $this->injectablePropertiesByPublicProperty; }
[ "public", "function", "getInjectablePropertiesByPublicProperty", "(", ")", "{", "if", "(", "$", "this", "->", "injectablePropertiesByPublicProperty", "===", "null", ")", "{", "$", "moufProperties", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", ...
Returns the list of MoufPropertyDescriptor that can be injected via a public property of the class. @return MoufPropertyDescriptor[] An associative array. The key is the name of the argument.
[ "Returns", "the", "list", "of", "MoufPropertyDescriptor", "that", "can", "be", "injected", "via", "a", "public", "property", "of", "the", "class", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/MoufReflectionClass.php#L424-L440
train
thecodingmachine/mouf
src/Mouf/Reflection/MoufReflectionClass.php
MoufReflectionClass.staticGetInjectablePropertiesBySetter
public static function staticGetInjectablePropertiesBySetter(MoufReflectionClassInterface $refClass) { $moufProperties = array(); foreach($refClass->getMethodsByPattern('^set..*') as $method) { /* @var $attribute MoufXmlReflectionProperty */ //if ($method->hasAnnotation("Property")) { $parameters = $method->getParameters(); if (count($parameters) == 0) { continue; } if (count($parameters)>1) { $ko = false; for ($i=1, $count=count($parameters); $i<$count; $i++) { $param = $parameters[$i]; if (!$param->isDefaultValueAvailable()) { $ko = true; } } if ($ko) { continue; } } $propertyDescriptor = new MoufPropertyDescriptor($method); $moufProperties[$method->getName()] = $propertyDescriptor; //} } return $moufProperties; }
php
public static function staticGetInjectablePropertiesBySetter(MoufReflectionClassInterface $refClass) { $moufProperties = array(); foreach($refClass->getMethodsByPattern('^set..*') as $method) { /* @var $attribute MoufXmlReflectionProperty */ //if ($method->hasAnnotation("Property")) { $parameters = $method->getParameters(); if (count($parameters) == 0) { continue; } if (count($parameters)>1) { $ko = false; for ($i=1, $count=count($parameters); $i<$count; $i++) { $param = $parameters[$i]; if (!$param->isDefaultValueAvailable()) { $ko = true; } } if ($ko) { continue; } } $propertyDescriptor = new MoufPropertyDescriptor($method); $moufProperties[$method->getName()] = $propertyDescriptor; //} } return $moufProperties; }
[ "public", "static", "function", "staticGetInjectablePropertiesBySetter", "(", "MoufReflectionClassInterface", "$", "refClass", ")", "{", "$", "moufProperties", "=", "array", "(", ")", ";", "foreach", "(", "$", "refClass", "->", "getMethodsByPattern", "(", "'^set..*'",...
We need this static method because we cannot use traits for PHP 5.3 that would have been useful to provide those methods to both MoufReflectionClass and MoufXMLReflectionClass. @param MoufReflectionClassInterface $refClass @return multitype:\Mouf\MoufPropertyDescriptor
[ "We", "need", "this", "static", "method", "because", "we", "cannot", "use", "traits", "for", "PHP", "5", ".", "3", "that", "would", "have", "been", "useful", "to", "provide", "those", "methods", "to", "both", "MoufReflectionClass", "and", "MoufXMLReflectionCla...
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/MoufReflectionClass.php#L477-L505
train
thecodingmachine/mouf
src/Mouf/Reflection/MoufReflectionClass.php
MoufReflectionClass.getLastModificationDate
protected function getLastModificationDate() { $parent = $this->getParentClass(); if ($parent != null) { return max(filemtime($this->getFileName()), $parent->getLastModificationDate()); } else { return filemtime($this->getFileName()); } }
php
protected function getLastModificationDate() { $parent = $this->getParentClass(); if ($parent != null) { return max(filemtime($this->getFileName()), $parent->getLastModificationDate()); } else { return filemtime($this->getFileName()); } }
[ "protected", "function", "getLastModificationDate", "(", ")", "{", "$", "parent", "=", "$", "this", "->", "getParentClass", "(", ")", ";", "if", "(", "$", "parent", "!=", "null", ")", "{", "return", "max", "(", "filemtime", "(", "$", "this", "->", "get...
Returns the last modification date of this file or one of the parent classes of this file. This return actually the last modification date of this file and all parents classes. This is useful to discard cache records if this file or one of its parents is updated. TODO: take traits into account.
[ "Returns", "the", "last", "modification", "date", "of", "this", "file", "or", "one", "of", "the", "parent", "classes", "of", "this", "file", ".", "This", "return", "actually", "the", "last", "modification", "date", "of", "this", "file", "and", "all", "pare...
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/MoufReflectionClass.php#L565-L572
train
thecodingmachine/mouf
src/Mouf/Reflection/MoufReflectionClass.php
MoufReflectionClass.getUseNamespaces
public function getUseNamespaces() { if ($this->useNamespaces === null) { $this->useNamespaces = array(); // Optim from Doctrine / Symfony 2: let's not analyze the "use" statements after the start of the class! $contents = $this->getFileContent($this->getFileName(), $this->getStartLine()); //$contents = file_get_contents($this->getFileName()); // Optim to avoid doing the token_get_all think that is costly. if (strpos($contents, 'use ') === false) { return array(); } $tokens = token_get_all($contents); $classes = array(); //$namespace = ''; for ($i = 0, $max = count($tokens); $i < $max; $i++) { $token = $tokens[$i]; if (is_string($token)) { continue; } $class = ''; $path = ''; if ($token[0] == T_USE) { while (($t = $tokens[++$i]) && is_array($t)) { //if (in_array($t[0], array(T_STRING, T_NS_SEPARATOR))) { $type = $t[0]; if ($type == T_STRING || $type == T_NS_SEPARATOR) { $path .= $t[1]; if ($type == T_STRING) { $as = $t[1]; } } elseif ($type === T_AS) { break; } } if (empty($path)) { // Path can be empty if the USE statement is not at the beginning of the file but part of a closure // (function() use ($var)) continue; } $nextToken = $tokens[$i]; if ($nextToken[0] === T_AS) { $i += 2; $as = $tokens[$i][1]; } $path = ltrim($path, '\\'); $this->useNamespaces[$as] = $path; } } } return $this->useNamespaces; }
php
public function getUseNamespaces() { if ($this->useNamespaces === null) { $this->useNamespaces = array(); // Optim from Doctrine / Symfony 2: let's not analyze the "use" statements after the start of the class! $contents = $this->getFileContent($this->getFileName(), $this->getStartLine()); //$contents = file_get_contents($this->getFileName()); // Optim to avoid doing the token_get_all think that is costly. if (strpos($contents, 'use ') === false) { return array(); } $tokens = token_get_all($contents); $classes = array(); //$namespace = ''; for ($i = 0, $max = count($tokens); $i < $max; $i++) { $token = $tokens[$i]; if (is_string($token)) { continue; } $class = ''; $path = ''; if ($token[0] == T_USE) { while (($t = $tokens[++$i]) && is_array($t)) { //if (in_array($t[0], array(T_STRING, T_NS_SEPARATOR))) { $type = $t[0]; if ($type == T_STRING || $type == T_NS_SEPARATOR) { $path .= $t[1]; if ($type == T_STRING) { $as = $t[1]; } } elseif ($type === T_AS) { break; } } if (empty($path)) { // Path can be empty if the USE statement is not at the beginning of the file but part of a closure // (function() use ($var)) continue; } $nextToken = $tokens[$i]; if ($nextToken[0] === T_AS) { $i += 2; $as = $tokens[$i][1]; } $path = ltrim($path, '\\'); $this->useNamespaces[$as] = $path; } } } return $this->useNamespaces; }
[ "public", "function", "getUseNamespaces", "(", ")", "{", "if", "(", "$", "this", "->", "useNamespaces", "===", "null", ")", "{", "$", "this", "->", "useNamespaces", "=", "array", "(", ")", ";", "// Optim from Doctrine / Symfony 2: let's not analyze the \"use\" state...
For the current class, returns a list of "use" statement used in the file for that class. The key is the "alias" of the path, and the value the path. So if you have: use Mouf\Mvc\Splash\Controller as SplashController the key will be "SplashController" and the value "Mouf\Mvc\Splash\Controller" Similarly, if you have only use Mouf\Mvc\Splash\Controller the key will be "Controller" and the value "Mouf\Mvc\Splash\Controller" @return array<string, string>
[ "For", "the", "current", "class", "returns", "a", "list", "of", "use", "statement", "used", "in", "the", "file", "for", "that", "class", ".", "The", "key", "is", "the", "alias", "of", "the", "path", "and", "the", "value", "the", "path", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/MoufReflectionClass.php#L697-L759
train
thecodingmachine/mouf
src/Mouf/Reflection/MoufPhpDocComment.php
MoufPhpDocComment.parse
private function parse($docComment) { $lines = self::getDocLinesFromComment($docComment); // First, let's go to the first Annotation. // Anything before is the pure comment. $annotationLines = array(); $oneAnnotationFound = false; // Is the line an annotation? Let's test this with a regexp. foreach ($lines as $line) { if (preg_match("/^[@][a-zA-Z]/", $line) === 0) { if ($oneAnnotationFound == false) { $this->comment .= $line."\n"; } } else { $this->parseAnnotation($line); $oneAnnotationFound = true; } } }
php
private function parse($docComment) { $lines = self::getDocLinesFromComment($docComment); // First, let's go to the first Annotation. // Anything before is the pure comment. $annotationLines = array(); $oneAnnotationFound = false; // Is the line an annotation? Let's test this with a regexp. foreach ($lines as $line) { if (preg_match("/^[@][a-zA-Z]/", $line) === 0) { if ($oneAnnotationFound == false) { $this->comment .= $line."\n"; } } else { $this->parseAnnotation($line); $oneAnnotationFound = true; } } }
[ "private", "function", "parse", "(", "$", "docComment", ")", "{", "$", "lines", "=", "self", "::", "getDocLinesFromComment", "(", "$", "docComment", ")", ";", "// First, let's go to the first Annotation.\r", "// Anything before is the pure comment.\r", "$", "annotationLin...
Parses the doc comment and initilizes all the values of interest. @param string $docComment
[ "Parses", "the", "doc", "comment", "and", "initilizes", "all", "the", "values", "of", "interest", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/MoufPhpDocComment.php#L59-L78
train
thecodingmachine/mouf
src/Mouf/Reflection/MoufPhpDocComment.php
MoufPhpDocComment.parseAnnotation
private function parseAnnotation($line) { // Let's get the annotation text preg_match("/^[@]([a-zA-Z][a-zA-Z0-9]*)(.*)/", $line, $values); $annotationClass = isset($values[1])?$values[1]:null; $annotationParams = trim(isset($values[2])?$values[2]:null); $this->annotationsArrayAsString[$annotationClass][] = $annotationParams; }
php
private function parseAnnotation($line) { // Let's get the annotation text preg_match("/^[@]([a-zA-Z][a-zA-Z0-9]*)(.*)/", $line, $values); $annotationClass = isset($values[1])?$values[1]:null; $annotationParams = trim(isset($values[2])?$values[2]:null); $this->annotationsArrayAsString[$annotationClass][] = $annotationParams; }
[ "private", "function", "parseAnnotation", "(", "$", "line", ")", "{", "// Let's get the annotation text\r", "preg_match", "(", "\"/^[@]([a-zA-Z][a-zA-Z0-9]*)(.*)/\"", ",", "$", "line", ",", "$", "values", ")", ";", "$", "annotationClass", "=", "isset", "(", "$", "...
Parses an annotation line and stores the result in the MoufPhpDocComment. @param string $line
[ "Parses", "an", "annotation", "line", "and", "stores", "the", "result", "in", "the", "MoufPhpDocComment", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/MoufPhpDocComment.php#L85-L93
train
thecodingmachine/mouf
src/Mouf/Reflection/MoufPhpDocComment.php
MoufPhpDocComment.getDocLinesFromComment
private static function getDocLinesFromComment($docComment) { if (strpos($docComment, "/**") === 0) { $docComment = substr($docComment, 3); } // Let's remove all the \r... $docComment = str_replace("\r", "", $docComment); $commentLines = explode("\n", $docComment); $commentLinesWithoutStars = array(); // For each line, let's remove the first spaces, and the first * foreach ($commentLines as $commentLine) { $length = strlen($commentLine); for ($i=0; $i<$length; $i++) { if ($commentLine{$i} != ' ' && $commentLine{$i} != '*' && $commentLine{$i} != "\t") { break; } } $commentLinesWithoutStars[] = substr($commentLine, $i); } // Let's remove the trailing /: $lastComment = $commentLinesWithoutStars[count($commentLinesWithoutStars)-1]; $commentLinesWithoutStars[count($commentLinesWithoutStars)-1] = substr($lastComment, 0, strlen($lastComment)-1); if ($commentLinesWithoutStars[count($commentLinesWithoutStars)-1] == "") array_pop($commentLinesWithoutStars); if (isset($commentLinesWithoutStars[0]) && $commentLinesWithoutStars[0] == "") { $commentLinesWithoutStars = array_slice($commentLinesWithoutStars, 1); } return $commentLinesWithoutStars; }
php
private static function getDocLinesFromComment($docComment) { if (strpos($docComment, "/**") === 0) { $docComment = substr($docComment, 3); } // Let's remove all the \r... $docComment = str_replace("\r", "", $docComment); $commentLines = explode("\n", $docComment); $commentLinesWithoutStars = array(); // For each line, let's remove the first spaces, and the first * foreach ($commentLines as $commentLine) { $length = strlen($commentLine); for ($i=0; $i<$length; $i++) { if ($commentLine{$i} != ' ' && $commentLine{$i} != '*' && $commentLine{$i} != "\t") { break; } } $commentLinesWithoutStars[] = substr($commentLine, $i); } // Let's remove the trailing /: $lastComment = $commentLinesWithoutStars[count($commentLinesWithoutStars)-1]; $commentLinesWithoutStars[count($commentLinesWithoutStars)-1] = substr($lastComment, 0, strlen($lastComment)-1); if ($commentLinesWithoutStars[count($commentLinesWithoutStars)-1] == "") array_pop($commentLinesWithoutStars); if (isset($commentLinesWithoutStars[0]) && $commentLinesWithoutStars[0] == "") { $commentLinesWithoutStars = array_slice($commentLinesWithoutStars, 1); } return $commentLinesWithoutStars; }
[ "private", "static", "function", "getDocLinesFromComment", "(", "$", "docComment", ")", "{", "if", "(", "strpos", "(", "$", "docComment", ",", "\"/**\"", ")", "===", "0", ")", "{", "$", "docComment", "=", "substr", "(", "$", "docComment", ",", "3", ")", ...
Returns an array of lines of the comments. @param string $docComment @return array
[ "Returns", "an", "array", "of", "lines", "of", "the", "comments", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/MoufPhpDocComment.php#L101-L135
train
thecodingmachine/mouf
src/Mouf/Reflection/MoufPhpDocComment.php
MoufPhpDocComment.getAllAnnotations
public function getAllAnnotations() { $retArray = array(); if (!$this->annotationsArrayAsString) { return array(); } foreach ($this->annotationsArrayAsString as $key=>$value) { $retArray[$key] = $this->getAnnotations($key); } return $retArray; }
php
public function getAllAnnotations() { $retArray = array(); if (!$this->annotationsArrayAsString) { return array(); } foreach ($this->annotationsArrayAsString as $key=>$value) { $retArray[$key] = $this->getAnnotations($key); } return $retArray; }
[ "public", "function", "getAllAnnotations", "(", ")", "{", "$", "retArray", "=", "array", "(", ")", ";", "if", "(", "!", "$", "this", "->", "annotationsArrayAsString", ")", "{", "return", "array", "(", ")", ";", "}", "foreach", "(", "$", "this", "->", ...
Returns a map associating the annotation title to an array of objects representing the annotation. @var array("annotationClass"=>array($annotationObjects))
[ "Returns", "a", "map", "associating", "the", "annotation", "title", "to", "an", "array", "of", "objects", "representing", "the", "annotation", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/MoufPhpDocComment.php#L225-L234
train
Lecturize/Laravel-Taxonomies
src/Models/Taxonomy.php
Taxonomy.scopeTerm
public function scopeTerm($query, $term, $taxonomy = 'major') { return $query->whereHas('term', function($q) use($term, $taxonomy) { $q->where('name', $term); }); }
php
public function scopeTerm($query, $term, $taxonomy = 'major') { return $query->whereHas('term', function($q) use($term, $taxonomy) { $q->where('name', $term); }); }
[ "public", "function", "scopeTerm", "(", "$", "query", ",", "$", "term", ",", "$", "taxonomy", "=", "'major'", ")", "{", "return", "$", "query", "->", "whereHas", "(", "'term'", ",", "function", "(", "$", "q", ")", "use", "(", "$", "term", ",", "$",...
Scope terms. @param object $query @param string $term @param string $taxonomy @return mixed
[ "Scope", "terms", "." ]
46774dbfef61131cf8f3fd9a2ab5c2ef4fccd6be
https://github.com/Lecturize/Laravel-Taxonomies/blob/46774dbfef61131cf8f3fd9a2ab5c2ef4fccd6be/src/Models/Taxonomy.php#L99-L104
train
Lecturize/Laravel-Taxonomies
src/Models/Taxonomy.php
Taxonomy.scopeSearch
public function scopeSearch($query, $searchTerm, $taxonomy = 'major') { return $query->whereHas('term', function($q) use($searchTerm, $taxonomy) { $q->where('name', 'like', '%'. $searchTerm .'%'); }); }
php
public function scopeSearch($query, $searchTerm, $taxonomy = 'major') { return $query->whereHas('term', function($q) use($searchTerm, $taxonomy) { $q->where('name', 'like', '%'. $searchTerm .'%'); }); }
[ "public", "function", "scopeSearch", "(", "$", "query", ",", "$", "searchTerm", ",", "$", "taxonomy", "=", "'major'", ")", "{", "return", "$", "query", "->", "whereHas", "(", "'term'", ",", "function", "(", "$", "q", ")", "use", "(", "$", "searchTerm",...
A simple search scope. @param object $query @param string $searchTerm @param string $taxonomy @return mixed
[ "A", "simple", "search", "scope", "." ]
46774dbfef61131cf8f3fd9a2ab5c2ef4fccd6be
https://github.com/Lecturize/Laravel-Taxonomies/blob/46774dbfef61131cf8f3fd9a2ab5c2ef4fccd6be/src/Models/Taxonomy.php#L114-L119
train
thecodingmachine/mouf
src-dev/Mouf/Controllers/MoufDisplayGraphController.php
MoufDisplayGraphController.defaultAction
public function defaultAction($name, $selfedit = false) { $this->initController($name, $selfedit); $template = $this->template; $this->template->addHeadHtmlElement(new HtmlJSJit()); $this->template->addJsFile(ROOT_URL."src-dev/views/displayGraph.js"); $template->addContentFile(dirname(__FILE__)."/../views/displayGraph.php", $this); $template->toHtml(); }
php
public function defaultAction($name, $selfedit = false) { $this->initController($name, $selfedit); $template = $this->template; $this->template->addHeadHtmlElement(new HtmlJSJit()); $this->template->addJsFile(ROOT_URL."src-dev/views/displayGraph.js"); $template->addContentFile(dirname(__FILE__)."/../views/displayGraph.php", $this); $template->toHtml(); }
[ "public", "function", "defaultAction", "(", "$", "name", ",", "$", "selfedit", "=", "false", ")", "{", "$", "this", "->", "initController", "(", "$", "name", ",", "$", "selfedit", ")", ";", "$", "template", "=", "$", "this", "->", "template", ";", "$...
Displays the dependency graph around the component passed in parameter. @Action @Logged @param string $name @param string $selfedit
[ "Displays", "the", "dependency", "graph", "around", "the", "component", "passed", "in", "parameter", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/MoufDisplayGraphController.php#L30-L38
train
thecodingmachine/mouf
src-dev/Mouf/Controllers/MoufDisplayGraphController.php
MoufDisplayGraphController.getJitJsonNode
private function getJitJsonNode($instanceName) { $node = array(); $node["id"] = $instanceName; $node["name"] = $instanceName; // We can set some data (dimension, other keys...) but we will keep tht to 0 for now. $adjacencies = array(); $componentsList = $this->getComponentsListBoundToInstance($instanceName); foreach ($componentsList as $component) { $adjacency = array(); $adjacency['nodeTo'] = $component; // We can set some data (weight...) but we will keep tht to 0 for now. $data = array(); $data['$type'] = "arrow"; $data['$direction'] = array($instanceName, $component); /* "data": { "$type":"arrow", "$direction": ["node4", "node3"], "$dim":25, "$color":"#dd99dd", "weight": 1 }*/ $adjacency['data'] = $data; $adjacencies[] = $adjacency; } $node["adjacencies"] = $adjacencies; return $node; }
php
private function getJitJsonNode($instanceName) { $node = array(); $node["id"] = $instanceName; $node["name"] = $instanceName; // We can set some data (dimension, other keys...) but we will keep tht to 0 for now. $adjacencies = array(); $componentsList = $this->getComponentsListBoundToInstance($instanceName); foreach ($componentsList as $component) { $adjacency = array(); $adjacency['nodeTo'] = $component; // We can set some data (weight...) but we will keep tht to 0 for now. $data = array(); $data['$type'] = "arrow"; $data['$direction'] = array($instanceName, $component); /* "data": { "$type":"arrow", "$direction": ["node4", "node3"], "$dim":25, "$color":"#dd99dd", "weight": 1 }*/ $adjacency['data'] = $data; $adjacencies[] = $adjacency; } $node["adjacencies"] = $adjacencies; return $node; }
[ "private", "function", "getJitJsonNode", "(", "$", "instanceName", ")", "{", "$", "node", "=", "array", "(", ")", ";", "$", "node", "[", "\"id\"", "]", "=", "$", "instanceName", ";", "$", "node", "[", "\"name\"", "]", "=", "$", "instanceName", ";", "...
Returns a PHP array representing a node that will be used by JIT to build a visual representation.
[ "Returns", "a", "PHP", "array", "representing", "a", "node", "that", "will", "be", "used", "by", "JIT", "to", "build", "a", "visual", "representation", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/MoufDisplayGraphController.php#L142-L178
train
thecodingmachine/mouf
src-dev/Mouf/Controllers/MoufDisplayGraphController.php
MoufDisplayGraphController.getComponentsListBoundToInstance
private function getComponentsListBoundToInstance($instanceName) { $componentsList = array(); $boundComponents = $this->moufManager->getBoundComponents($instanceName); if (is_array($boundComponents)) { foreach ($boundComponents as $property=>$components) { if (is_array($components)) { $componentsList = array_merge($componentsList, $components); } else { $componentsList[] = $components; } } } return $componentsList; }
php
private function getComponentsListBoundToInstance($instanceName) { $componentsList = array(); $boundComponents = $this->moufManager->getBoundComponents($instanceName); if (is_array($boundComponents)) { foreach ($boundComponents as $property=>$components) { if (is_array($components)) { $componentsList = array_merge($componentsList, $components); } else { $componentsList[] = $components; } } } return $componentsList; }
[ "private", "function", "getComponentsListBoundToInstance", "(", "$", "instanceName", ")", "{", "$", "componentsList", "=", "array", "(", ")", ";", "$", "boundComponents", "=", "$", "this", "->", "moufManager", "->", "getBoundComponents", "(", "$", "instanceName", ...
Returns the list of components that this component possesses bindings on. @param string $instanceName @return array<string>
[ "Returns", "the", "list", "of", "components", "that", "this", "component", "possesses", "bindings", "on", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/MoufDisplayGraphController.php#L186-L200
train
thecodingmachine/mouf
src-dev/Mouf/Validator/MoufValidatorService.php
MoufValidatorService.registerBasicValidator
public function registerBasicValidator($name, $url, $propagatedUrlParameters = null) { $this->validators[] = new MoufBasicValidationProvider($name, $url, $propagatedUrlParameters); }
php
public function registerBasicValidator($name, $url, $propagatedUrlParameters = null) { $this->validators[] = new MoufBasicValidationProvider($name, $url, $propagatedUrlParameters); }
[ "public", "function", "registerBasicValidator", "(", "$", "name", ",", "$", "url", ",", "$", "propagatedUrlParameters", "=", "null", ")", "{", "$", "this", "->", "validators", "[", "]", "=", "new", "MoufBasicValidationProvider", "(", "$", "name", ",", "$", ...
Registers dynamically a new validator. @param string $name @param string $url @param array<string> $propagatedUrlParameters
[ "Registers", "dynamically", "a", "new", "validator", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Validator/MoufValidatorService.php#L100-L102
train
thecodingmachine/mouf
src/Mouf/MoufGroupDescriptor.php
MoufGroupDescriptor.getJsonArray
public function getJsonArray() { $array = array(); if (!empty($this->subGroups)) { $array['subgroups'] = array(); foreach ($this->subGroups as $name => $subGroup) { $array['subgroups'][$name] = $subGroup->getJsonArray(); } } if (!empty($this->packages)) { $array['packages'] = array(); foreach ($this->packages as $name => $package) { /* @var $package MoufPackageVersionsContainer */ $array['packages'][$name] = $package->getJsonArray(); } } return $array; }
php
public function getJsonArray() { $array = array(); if (!empty($this->subGroups)) { $array['subgroups'] = array(); foreach ($this->subGroups as $name => $subGroup) { $array['subgroups'][$name] = $subGroup->getJsonArray(); } } if (!empty($this->packages)) { $array['packages'] = array(); foreach ($this->packages as $name => $package) { /* @var $package MoufPackageVersionsContainer */ $array['packages'][$name] = $package->getJsonArray(); } } return $array; }
[ "public", "function", "getJsonArray", "(", ")", "{", "$", "array", "=", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "subGroups", ")", ")", "{", "$", "array", "[", "'subgroups'", "]", "=", "array", "(", ")", ";", "fore...
Returns a PHP array that describes the group. The array does not contain all available information, only enough information to display the list of packages in the Mouf interface. The structure of the array is: array("subGroups" => array('subGroupName' => subGroupArray, 'packages' => array('packageName', packageArray) return array
[ "Returns", "a", "PHP", "array", "that", "describes", "the", "group", ".", "The", "array", "does", "not", "contain", "all", "available", "information", "only", "enough", "information", "to", "display", "the", "list", "of", "packages", "in", "the", "Mouf", "in...
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufGroupDescriptor.php#L113-L129
train
thecodingmachine/mouf
src-dev/Mouf/Controllers/MoufAjaxInstanceController.php
MoufAjaxInstanceController.index
public function index($name, $selfedit = false) { $this->initController($name, $selfedit); $this->template->getWebLibraryManager()->addLibrary(new WebLibrary(["vendor/mouf/javascript.ace/src-min-noconflict/ace.js"])); $this->contentBlock->addFile(dirname(__FILE__)."/../../views/instances/viewInstance.php", $this); $this->rightBlock->addText("<div id='instanceList'></div>"); $this->template->toHtml(); }
php
public function index($name, $selfedit = false) { $this->initController($name, $selfedit); $this->template->getWebLibraryManager()->addLibrary(new WebLibrary(["vendor/mouf/javascript.ace/src-min-noconflict/ace.js"])); $this->contentBlock->addFile(dirname(__FILE__)."/../../views/instances/viewInstance.php", $this); $this->rightBlock->addText("<div id='instanceList'></div>"); $this->template->toHtml(); }
[ "public", "function", "index", "(", "$", "name", ",", "$", "selfedit", "=", "false", ")", "{", "$", "this", "->", "initController", "(", "$", "name", ",", "$", "selfedit", ")", ";", "$", "this", "->", "template", "->", "getWebLibraryManager", "(", ")",...
Displays the page to edit an instance. @Action @Logged @param string $name the name of the component to display @param string $selfedit If true, the name of the component must be a component from the Mouf framework itself (internal use only)
[ "Displays", "the", "page", "to", "edit", "an", "instance", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/MoufAjaxInstanceController.php#L37-L45
train
thecodingmachine/mouf
src-dev/Mouf/Menu/ChooseInstanceMenuItem.php
ChooseInstanceMenuItem.getLink
public function getLink() { $url = 'javascript:chooseInstancePopup('.json_encode($this->type).', "'.ROOT_URL.$this->getUrl().'?name=", "'.ROOT_URL.'")'; return $url; }
php
public function getLink() { $url = 'javascript:chooseInstancePopup('.json_encode($this->type).', "'.ROOT_URL.$this->getUrl().'?name=", "'.ROOT_URL.'")'; return $url; }
[ "public", "function", "getLink", "(", ")", "{", "$", "url", "=", "'javascript:chooseInstancePopup('", ".", "json_encode", "(", "$", "this", "->", "type", ")", ".", "', \"'", ".", "ROOT_URL", ".", "$", "this", "->", "getUrl", "(", ")", ".", "'?name=\", \"'"...
Returns the URL for this menu. This URL is actually Javascript that will display the menu. @return string
[ "Returns", "the", "URL", "for", "this", "menu", ".", "This", "URL", "is", "actually", "Javascript", "that", "will", "display", "the", "menu", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Menu/ChooseInstanceMenuItem.php#L45-L48
train
Lecturize/Laravel-Taxonomies
src/Traits/HasTaxonomies.php
HasTaxonomies.addTerm
public function addTerm($terms, $taxonomy, $parent = 0, $order = 0) { $terms = TaxableUtils::makeTermsArray($terms); $this->createTaxables($terms, $taxonomy, $parent, $order); $terms = Term::whereIn('name', $terms)->pluck('id')->all(); if (count($terms) > 0) { foreach ($terms as $term) { if ($this->taxonomies()->where('taxonomy', $taxonomy)->where('term_id', $term)->first()) continue; $tax = Taxonomy::where('term_id', $term)->first(); $this->taxonomies()->attach($tax->id); } return; } $this->taxonomies()->detach(); }
php
public function addTerm($terms, $taxonomy, $parent = 0, $order = 0) { $terms = TaxableUtils::makeTermsArray($terms); $this->createTaxables($terms, $taxonomy, $parent, $order); $terms = Term::whereIn('name', $terms)->pluck('id')->all(); if (count($terms) > 0) { foreach ($terms as $term) { if ($this->taxonomies()->where('taxonomy', $taxonomy)->where('term_id', $term)->first()) continue; $tax = Taxonomy::where('term_id', $term)->first(); $this->taxonomies()->attach($tax->id); } return; } $this->taxonomies()->detach(); }
[ "public", "function", "addTerm", "(", "$", "terms", ",", "$", "taxonomy", ",", "$", "parent", "=", "0", ",", "$", "order", "=", "0", ")", "{", "$", "terms", "=", "TaxableUtils", "::", "makeTermsArray", "(", "$", "terms", ")", ";", "$", "this", "->"...
Add one or multiple terms in a given taxonomy. @param mixed $terms @param string $taxonomy @param integer $parent @param integer $order
[ "Add", "one", "or", "multiple", "terms", "in", "a", "given", "taxonomy", "." ]
46774dbfef61131cf8f3fd9a2ab5c2ef4fccd6be
https://github.com/Lecturize/Laravel-Taxonomies/blob/46774dbfef61131cf8f3fd9a2ab5c2ef4fccd6be/src/Traits/HasTaxonomies.php#L42-L63
train
Lecturize/Laravel-Taxonomies
src/Traits/HasTaxonomies.php
HasTaxonomies.getTerms
public function getTerms($taxonomy = '') { if ($taxonomy) { $term_ids = $this->taxonomies->where('taxonomy', $taxonomy)->pluck('term_id'); } else { $term_ids = $this->getTaxonomies('term_id'); } return Term::whereIn('id', $term_ids)->get(); }
php
public function getTerms($taxonomy = '') { if ($taxonomy) { $term_ids = $this->taxonomies->where('taxonomy', $taxonomy)->pluck('term_id'); } else { $term_ids = $this->getTaxonomies('term_id'); } return Term::whereIn('id', $term_ids)->get(); }
[ "public", "function", "getTerms", "(", "$", "taxonomy", "=", "''", ")", "{", "if", "(", "$", "taxonomy", ")", "{", "$", "term_ids", "=", "$", "this", "->", "taxonomies", "->", "where", "(", "'taxonomy'", ",", "$", "taxonomy", ")", "->", "pluck", "(",...
Get the terms related to a given taxonomy. @param string $taxonomy @return mixed
[ "Get", "the", "terms", "related", "to", "a", "given", "taxonomy", "." ]
46774dbfef61131cf8f3fd9a2ab5c2ef4fccd6be
https://github.com/Lecturize/Laravel-Taxonomies/blob/46774dbfef61131cf8f3fd9a2ab5c2ef4fccd6be/src/Traits/HasTaxonomies.php#L122-L131
train
Lecturize/Laravel-Taxonomies
src/Traits/HasTaxonomies.php
HasTaxonomies.getTerm
public function getTerm($term_name, $taxonomy = '') { if ($taxonomy) { $term_ids = $this->taxonomies->where('taxonomy', $taxonomy)->pluck('term_id'); } else { $term_ids = $this->getTaxonomies('term_id'); } return Term::whereIn('id', $term_ids)->where('name', $term_name)->first(); }
php
public function getTerm($term_name, $taxonomy = '') { if ($taxonomy) { $term_ids = $this->taxonomies->where('taxonomy', $taxonomy)->pluck('term_id'); } else { $term_ids = $this->getTaxonomies('term_id'); } return Term::whereIn('id', $term_ids)->where('name', $term_name)->first(); }
[ "public", "function", "getTerm", "(", "$", "term_name", ",", "$", "taxonomy", "=", "''", ")", "{", "if", "(", "$", "taxonomy", ")", "{", "$", "term_ids", "=", "$", "this", "->", "taxonomies", "->", "where", "(", "'taxonomy'", ",", "$", "taxonomy", ")...
Get a term model by the given name and optionally a taxonomy. @param string $term_name @param string $taxonomy @return mixed
[ "Get", "a", "term", "model", "by", "the", "given", "name", "and", "optionally", "a", "taxonomy", "." ]
46774dbfef61131cf8f3fd9a2ab5c2ef4fccd6be
https://github.com/Lecturize/Laravel-Taxonomies/blob/46774dbfef61131cf8f3fd9a2ab5c2ef4fccd6be/src/Traits/HasTaxonomies.php#L140-L149
train
Lecturize/Laravel-Taxonomies
src/Traits/HasTaxonomies.php
HasTaxonomies.removeTerm
public function removeTerm($term_name, $taxonomy = '') { if (! $term = $this->getTerm($term_name, $taxonomy)) return null; if ($taxonomy) { $taxonomy = $this->taxonomies->where('taxonomy', $taxonomy)->where('term_id', $term->id)->first(); } else { $taxonomy = $this->taxonomies->where('term_id', $term->id)->first(); } return $this->taxed()->where('taxonomy_id', $taxonomy->id)->delete(); }
php
public function removeTerm($term_name, $taxonomy = '') { if (! $term = $this->getTerm($term_name, $taxonomy)) return null; if ($taxonomy) { $taxonomy = $this->taxonomies->where('taxonomy', $taxonomy)->where('term_id', $term->id)->first(); } else { $taxonomy = $this->taxonomies->where('term_id', $term->id)->first(); } return $this->taxed()->where('taxonomy_id', $taxonomy->id)->delete(); }
[ "public", "function", "removeTerm", "(", "$", "term_name", ",", "$", "taxonomy", "=", "''", ")", "{", "if", "(", "!", "$", "term", "=", "$", "this", "->", "getTerm", "(", "$", "term_name", ",", "$", "taxonomy", ")", ")", "return", "null", ";", "if"...
Disassociate the given term from this model. @param string $term_name @param string $taxonomy @return mixed
[ "Disassociate", "the", "given", "term", "from", "this", "model", "." ]
46774dbfef61131cf8f3fd9a2ab5c2ef4fccd6be
https://github.com/Lecturize/Laravel-Taxonomies/blob/46774dbfef61131cf8f3fd9a2ab5c2ef4fccd6be/src/Traits/HasTaxonomies.php#L170-L182
train
Lecturize/Laravel-Taxonomies
src/Traits/HasTaxonomies.php
HasTaxonomies.scopeWithTerms
public function scopeWithTerms($query, $terms, $taxonomy) { $terms = TaxableUtils::makeTermsArray($terms); foreach ($terms as $term) $this->scopeWithTerm($query, $term, $taxonomy); return $query; }
php
public function scopeWithTerms($query, $terms, $taxonomy) { $terms = TaxableUtils::makeTermsArray($terms); foreach ($terms as $term) $this->scopeWithTerm($query, $term, $taxonomy); return $query; }
[ "public", "function", "scopeWithTerms", "(", "$", "query", ",", "$", "terms", ",", "$", "taxonomy", ")", "{", "$", "terms", "=", "TaxableUtils", "::", "makeTermsArray", "(", "$", "terms", ")", ";", "foreach", "(", "$", "terms", "as", "$", "term", ")", ...
Scope by given terms. @param object $query @param array $terms @param string $taxonomy @return mixed
[ "Scope", "by", "given", "terms", "." ]
46774dbfef61131cf8f3fd9a2ab5c2ef4fccd6be
https://github.com/Lecturize/Laravel-Taxonomies/blob/46774dbfef61131cf8f3fd9a2ab5c2ef4fccd6be/src/Traits/HasTaxonomies.php#L202-L210
train
Lecturize/Laravel-Taxonomies
src/Traits/HasTaxonomies.php
HasTaxonomies.scopeWithTerm
public function scopeWithTerm($query, $term_name, $taxonomy) { $term_ids = Taxonomy::where('taxonomy', $taxonomy)->pluck('term_id'); $term = Term::whereIn('id', $term_ids)->where('name', $term_name)->first(); $taxonomy = Taxonomy::where('term_id', $term->id)->first(); return $query->whereHas('taxonomies', function($q) use($term, $taxonomy) { $q->where('term_id', $term->id); }); }
php
public function scopeWithTerm($query, $term_name, $taxonomy) { $term_ids = Taxonomy::where('taxonomy', $taxonomy)->pluck('term_id'); $term = Term::whereIn('id', $term_ids)->where('name', $term_name)->first(); $taxonomy = Taxonomy::where('term_id', $term->id)->first(); return $query->whereHas('taxonomies', function($q) use($term, $taxonomy) { $q->where('term_id', $term->id); }); }
[ "public", "function", "scopeWithTerm", "(", "$", "query", ",", "$", "term_name", ",", "$", "taxonomy", ")", "{", "$", "term_ids", "=", "Taxonomy", "::", "where", "(", "'taxonomy'", ",", "$", "taxonomy", ")", "->", "pluck", "(", "'term_id'", ")", ";", "...
Scope by the given term. @param object $query @param string $term_name @param string $taxonomy @return mixed
[ "Scope", "by", "the", "given", "term", "." ]
46774dbfef61131cf8f3fd9a2ab5c2ef4fccd6be
https://github.com/Lecturize/Laravel-Taxonomies/blob/46774dbfef61131cf8f3fd9a2ab5c2ef4fccd6be/src/Traits/HasTaxonomies.php#L220-L230
train
Lecturize/Laravel-Taxonomies
src/Traits/HasTaxonomies.php
HasTaxonomies.scopeHasCategory
public function scopeHasCategory($query, $taxonomy_id) { return $query->whereHas('taxed', function($q) use($taxonomy_id) { $q->where('taxonomy_id', $taxonomy_id); }); }
php
public function scopeHasCategory($query, $taxonomy_id) { return $query->whereHas('taxed', function($q) use($taxonomy_id) { $q->where('taxonomy_id', $taxonomy_id); }); }
[ "public", "function", "scopeHasCategory", "(", "$", "query", ",", "$", "taxonomy_id", ")", "{", "return", "$", "query", "->", "whereHas", "(", "'taxed'", ",", "function", "(", "$", "q", ")", "use", "(", "$", "taxonomy_id", ")", "{", "$", "q", "->", "...
Scope by category id. @param object $query @param integer $taxonomy_id @return mixed
[ "Scope", "by", "category", "id", "." ]
46774dbfef61131cf8f3fd9a2ab5c2ef4fccd6be
https://github.com/Lecturize/Laravel-Taxonomies/blob/46774dbfef61131cf8f3fd9a2ab5c2ef4fccd6be/src/Traits/HasTaxonomies.php#L259-L264
train
Lecturize/Laravel-Taxonomies
src/Traits/HasTaxonomies.php
HasTaxonomies.scopeHasCategories
public function scopeHasCategories($query, $taxonomy_ids) { return $query->whereHas('taxed', function($q) use($taxonomy_ids) { $q->whereIn('taxonomy_id', $taxonomy_ids); }); }
php
public function scopeHasCategories($query, $taxonomy_ids) { return $query->whereHas('taxed', function($q) use($taxonomy_ids) { $q->whereIn('taxonomy_id', $taxonomy_ids); }); }
[ "public", "function", "scopeHasCategories", "(", "$", "query", ",", "$", "taxonomy_ids", ")", "{", "return", "$", "query", "->", "whereHas", "(", "'taxed'", ",", "function", "(", "$", "q", ")", "use", "(", "$", "taxonomy_ids", ")", "{", "$", "q", "->",...
Scope by category ids. @param object $query @param array $taxonomy_ids @return mixed
[ "Scope", "by", "category", "ids", "." ]
46774dbfef61131cf8f3fd9a2ab5c2ef4fccd6be
https://github.com/Lecturize/Laravel-Taxonomies/blob/46774dbfef61131cf8f3fd9a2ab5c2ef4fccd6be/src/Traits/HasTaxonomies.php#L273-L278
train
thecodingmachine/mouf
src-dev/Mouf/Controllers/IncludesAnalyzerController.php
IncludesAnalyzerController.refresh
public function refresh($selfedit = "false") { $this->selfedit = $selfedit; $moufCache = new MoufCache(); $moufCache->purgeAll(); header("Location: .?selfedit=".$selfedit); }
php
public function refresh($selfedit = "false") { $this->selfedit = $selfedit; $moufCache = new MoufCache(); $moufCache->purgeAll(); header("Location: .?selfedit=".$selfedit); }
[ "public", "function", "refresh", "(", "$", "selfedit", "=", "\"false\"", ")", "{", "$", "this", "->", "selfedit", "=", "$", "selfedit", ";", "$", "moufCache", "=", "new", "MoufCache", "(", ")", ";", "$", "moufCache", "->", "purgeAll", "(", ")", ";", ...
Purge cache and redirects to analysis page. @Action @Logged @param string $selfedit
[ "Purge", "cache", "and", "redirects", "to", "analysis", "page", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/IncludesAnalyzerController.php#L134-L141
train
thecodingmachine/mouf
src-dev/Mouf/Controllers/DocumentationController.php
DocumentationController.displayDocDirectory
public function displayDocDirectory($docPages, $packageName) { ?> <ul> <?php foreach ($docPages as $docPage): $url = $docPage['url']; $title = $docPage['title']; ?> <li> <?php if ($url) { echo "<a href='view/".$packageName."/".$url."'>"; } echo $title; if ($url) { echo "</a>"; } /*if ($docPage->getChildren()) { displayDocDirectory($docPage->getChildren()); }*/ ?> </li> <?php endforeach; ?> </ul> <?php }
php
public function displayDocDirectory($docPages, $packageName) { ?> <ul> <?php foreach ($docPages as $docPage): $url = $docPage['url']; $title = $docPage['title']; ?> <li> <?php if ($url) { echo "<a href='view/".$packageName."/".$url."'>"; } echo $title; if ($url) { echo "</a>"; } /*if ($docPage->getChildren()) { displayDocDirectory($docPage->getChildren()); }*/ ?> </li> <?php endforeach; ?> </ul> <?php }
[ "public", "function", "displayDocDirectory", "(", "$", "docPages", ",", "$", "packageName", ")", "{", "?>\r\n<ul>\r\n\t\t<?php", "foreach", "(", "$", "docPages", "as", "$", "docPage", ")", ":", "$", "url", "=", "$", "docPage", "[", "'url'", "]", ";", "$", ...
Display the doc links for one package. @param array<string, string> $docPages @param string $packageName
[ "Display", "the", "doc", "links", "for", "one", "package", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/DocumentationController.php#L348-L375
train
thecodingmachine/mouf
src-dev/Mouf/Installer/ComposerInstaller.php
ComposerInstaller.save
public function save() { if ($this->installTasks === null) { return; } // Let's grab all install tasks and save them according to their scope. // If no scope is provided, we default to global scope. $localInstalls = array(); $globalInstalls = array(); foreach ($this->installTasks as $task) { switch ($task->getScope()) { case AbstractInstallTask::SCOPE_GLOBAL: case '': $globalInstalls[] = $task->toArray(); break; case AbstractInstallTask::SCOPE_LOCAL: $localInstalls[] = $task->toArray(); break; default: throw new MoufException("Unknown install task scope '".$task->getScope()."'."); } } $this->ensureWritable($this->globalInstallFile); $this->ensureWritable($this->localInstallFile); $fp = fopen($this->globalInstallFile, "w"); fwrite($fp, "<?php\n"); fwrite($fp, "/**\n"); fwrite($fp, " * This is a file automatically generated by the Mouf framework. Do not modify it, as it could be overwritten.\n"); fwrite($fp, " * This file contains the status of all Mouf global installation processes for packages you have installed.\n"); fwrite($fp, " * If you are working with a source repository, this file should be commited.\n"); fwrite($fp, " */\n"); fwrite($fp, "return ".var_export($globalInstalls, true).";"); fclose($fp); $fp = fopen($this->localInstallFile, "w"); fwrite($fp, "<?php\n"); fwrite($fp, "/**\n"); fwrite($fp, " * This is a file automatically generated by the Mouf framework. Do not modify it, as it could be overwritten.\n"); fwrite($fp, " * This file contains the status of all Mouf local installation processes for packages you have installed.\n"); fwrite($fp, " * If you are working with a source repository, this file should NOT be commited.\n"); fwrite($fp, " */\n"); fwrite($fp, "return ".var_export($localInstalls, true).";"); fclose($fp); @chmod($this->globalInstallFile, 0664); @chmod($this->localInstallFile, 0664); if (function_exists("opcache_invalidate")) { opcache_invalidate($this->globalInstallFile); opcache_invalidate($this->localInstallFile); } }
php
public function save() { if ($this->installTasks === null) { return; } // Let's grab all install tasks and save them according to their scope. // If no scope is provided, we default to global scope. $localInstalls = array(); $globalInstalls = array(); foreach ($this->installTasks as $task) { switch ($task->getScope()) { case AbstractInstallTask::SCOPE_GLOBAL: case '': $globalInstalls[] = $task->toArray(); break; case AbstractInstallTask::SCOPE_LOCAL: $localInstalls[] = $task->toArray(); break; default: throw new MoufException("Unknown install task scope '".$task->getScope()."'."); } } $this->ensureWritable($this->globalInstallFile); $this->ensureWritable($this->localInstallFile); $fp = fopen($this->globalInstallFile, "w"); fwrite($fp, "<?php\n"); fwrite($fp, "/**\n"); fwrite($fp, " * This is a file automatically generated by the Mouf framework. Do not modify it, as it could be overwritten.\n"); fwrite($fp, " * This file contains the status of all Mouf global installation processes for packages you have installed.\n"); fwrite($fp, " * If you are working with a source repository, this file should be commited.\n"); fwrite($fp, " */\n"); fwrite($fp, "return ".var_export($globalInstalls, true).";"); fclose($fp); $fp = fopen($this->localInstallFile, "w"); fwrite($fp, "<?php\n"); fwrite($fp, "/**\n"); fwrite($fp, " * This is a file automatically generated by the Mouf framework. Do not modify it, as it could be overwritten.\n"); fwrite($fp, " * This file contains the status of all Mouf local installation processes for packages you have installed.\n"); fwrite($fp, " * If you are working with a source repository, this file should NOT be commited.\n"); fwrite($fp, " */\n"); fwrite($fp, "return ".var_export($localInstalls, true).";"); fclose($fp); @chmod($this->globalInstallFile, 0664); @chmod($this->localInstallFile, 0664); if (function_exists("opcache_invalidate")) { opcache_invalidate($this->globalInstallFile); opcache_invalidate($this->localInstallFile); } }
[ "public", "function", "save", "(", ")", "{", "if", "(", "$", "this", "->", "installTasks", "===", "null", ")", "{", "return", ";", "}", "// Let's grab all install tasks and save them according to their scope.", "// If no scope is provided, we default to global scope.", "$",...
Saves any modified install task.
[ "Saves", "any", "modified", "install", "task", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Installer/ComposerInstaller.php#L67-L121
train
thecodingmachine/mouf
src-dev/Mouf/Installer/ComposerInstaller.php
ComposerInstaller.completeStatusFromInstallFile
private function completeStatusFromInstallFile(array $installStatuses) { foreach ($this->installTasks as $installTask) { /* @var $installTask AbstractInstallTask */ foreach ($installStatuses as $installStatus) { if ($installTask->matchesPackage($installStatus)) { $installTask->setStatus($installStatus['status']); } } } }
php
private function completeStatusFromInstallFile(array $installStatuses) { foreach ($this->installTasks as $installTask) { /* @var $installTask AbstractInstallTask */ foreach ($installStatuses as $installStatus) { if ($installTask->matchesPackage($installStatus)) { $installTask->setStatus($installStatus['status']); } } } }
[ "private", "function", "completeStatusFromInstallFile", "(", "array", "$", "installStatuses", ")", "{", "foreach", "(", "$", "this", "->", "installTasks", "as", "$", "installTask", ")", "{", "/* @var $installTask AbstractInstallTask */", "foreach", "(", "$", "installS...
Takes in input the array contained in an install file and completes the status of the install tasks from here. @param array $installStatuses
[ "Takes", "in", "input", "the", "array", "contained", "in", "an", "install", "file", "and", "completes", "the", "status", "of", "the", "install", "tasks", "from", "here", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Installer/ComposerInstaller.php#L208-L217
train
thecodingmachine/mouf
src-dev/Mouf/Installer/ComposerInstaller.php
ComposerInstaller.install
public function install(array $task) { // The kind of action to be performed is stored in a file (mouf/installActions.json) // This file contains an array that can be either: // { "type": "all" } => install all tasks marked "todo" // { "type": "one", "task": { // task details } } => install only the task passed in parameter self::ensureWritable($this->installStatusFile); file_put_contents($this->installStatusFile, json_encode( array("type"=>"one", "task"=>$task))); header("Location: ".MOUF_URL."installer/printInstallationScreen?selfedit=".json_encode($this->selfEdit)); }
php
public function install(array $task) { // The kind of action to be performed is stored in a file (mouf/installActions.json) // This file contains an array that can be either: // { "type": "all" } => install all tasks marked "todo" // { "type": "one", "task": { // task details } } => install only the task passed in parameter self::ensureWritable($this->installStatusFile); file_put_contents($this->installStatusFile, json_encode( array("type"=>"one", "task"=>$task))); header("Location: ".MOUF_URL."installer/printInstallationScreen?selfedit=".json_encode($this->selfEdit)); }
[ "public", "function", "install", "(", "array", "$", "task", ")", "{", "// The kind of action to be performed is stored in a file (mouf/installActions.json)", "// This file contains an array that can be either:", "// { \"type\": \"all\" } => install all tasks marked \"todo\"", "// { \"type\":...
Starts the install process for only only task. @param array $task
[ "Starts", "the", "install", "process", "for", "only", "only", "task", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Installer/ComposerInstaller.php#L274-L285
train
thecodingmachine/mouf
src-dev/Mouf/Installer/ComposerInstaller.php
ComposerInstaller.findInstallTaskFromArray
private function findInstallTaskFromArray(array $array) { $installTasks = $this->getInstallTasks(); foreach ($installTasks as $installTask) { if ($installTask->matchesPackage($array)) { return $installTask; } } throw new MoufException("Unable to find install task in matching array passed in parameter."); }
php
private function findInstallTaskFromArray(array $array) { $installTasks = $this->getInstallTasks(); foreach ($installTasks as $installTask) { if ($installTask->matchesPackage($array)) { return $installTask; } } throw new MoufException("Unable to find install task in matching array passed in parameter."); }
[ "private", "function", "findInstallTaskFromArray", "(", "array", "$", "array", ")", "{", "$", "installTasks", "=", "$", "this", "->", "getInstallTasks", "(", ")", ";", "foreach", "(", "$", "installTasks", "as", "$", "installTask", ")", "{", "if", "(", "$",...
Finds the InstallTask from the array representing it. @param array $array @return AbstractInstallTask
[ "Finds", "the", "InstallTask", "from", "the", "array", "representing", "it", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Installer/ComposerInstaller.php#L303-L312
train
thecodingmachine/mouf
src-dev/Mouf/Installer/ComposerInstaller.php
ComposerInstaller.validateCurrentInstall
public function validateCurrentInstall() { if (!file_exists($this->installStatusFile)) { throw new MoufException("No install status file found. I don't know what install task should be run."); } $statusArray = json_decode(file_get_contents($this->installStatusFile), true); if ($statusArray['type'] == 'one') { $taskArray = $statusArray['task']; // Now, let's find the matching task and mark it "done". $installTask = $this->findInstallTaskFromArray($taskArray); $installTask->setStatus(AbstractInstallTask::STATUS_DONE); $this->save(); // Finally, let's delete the install status file. unlink($this->installStatusFile); } else { $installTasks = $this->getInstallTasks(); foreach ($installTasks as $installTask) { if ($installTask->getStatus() == AbstractInstallTask::STATUS_TODO) { $installTask->setStatus(AbstractInstallTask::STATUS_DONE); $this->save(); break; } } $todoRemaining = false; foreach ($installTasks as $installTask) { if ($installTask->getStatus() == AbstractInstallTask::STATUS_TODO) { $todoRemaining = true; break; } } if (!$todoRemaining) { // Finally, let's delete the install status file if there are no actions in "todo" state unlink($this->installStatusFile); } } }
php
public function validateCurrentInstall() { if (!file_exists($this->installStatusFile)) { throw new MoufException("No install status file found. I don't know what install task should be run."); } $statusArray = json_decode(file_get_contents($this->installStatusFile), true); if ($statusArray['type'] == 'one') { $taskArray = $statusArray['task']; // Now, let's find the matching task and mark it "done". $installTask = $this->findInstallTaskFromArray($taskArray); $installTask->setStatus(AbstractInstallTask::STATUS_DONE); $this->save(); // Finally, let's delete the install status file. unlink($this->installStatusFile); } else { $installTasks = $this->getInstallTasks(); foreach ($installTasks as $installTask) { if ($installTask->getStatus() == AbstractInstallTask::STATUS_TODO) { $installTask->setStatus(AbstractInstallTask::STATUS_DONE); $this->save(); break; } } $todoRemaining = false; foreach ($installTasks as $installTask) { if ($installTask->getStatus() == AbstractInstallTask::STATUS_TODO) { $todoRemaining = true; break; } } if (!$todoRemaining) { // Finally, let's delete the install status file if there are no actions in "todo" state unlink($this->installStatusFile); } } }
[ "public", "function", "validateCurrentInstall", "(", ")", "{", "if", "(", "!", "file_exists", "(", "$", "this", "->", "installStatusFile", ")", ")", "{", "throw", "new", "MoufException", "(", "\"No install status file found. I don't know what install task should be run.\"...
Marks the current install task as "done".
[ "Marks", "the", "current", "install", "task", "as", "done", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Installer/ComposerInstaller.php#L346-L383
train
thecodingmachine/mouf
src/Mouf/Reflection/MoufAnnotationHelper.php
MoufAnnotationHelper.getValueAsList
public static function getValueAsList($value) { $tokens = token_get_all('<?php '.$value); $resultArray = array(); // Le's find all the strings, and let's put each string in the table. foreach ($tokens as $token) { if ($token[0] == T_CONSTANT_ENCAPSED_STRING) { $resultArray[] = substr($token[1], 1, strlen($token[1])-2) ; } } return $resultArray; }
php
public static function getValueAsList($value) { $tokens = token_get_all('<?php '.$value); $resultArray = array(); // Le's find all the strings, and let's put each string in the table. foreach ($tokens as $token) { if ($token[0] == T_CONSTANT_ENCAPSED_STRING) { $resultArray[] = substr($token[1], 1, strlen($token[1])-2) ; } } return $resultArray; }
[ "public", "static", "function", "getValueAsList", "(", "$", "value", ")", "{", "$", "tokens", "=", "token_get_all", "(", "'<?php '", ".", "$", "value", ")", ";", "$", "resultArray", "=", "array", "(", ")", ";", "// Le's find all the strings, and let's put each s...
Returns a list from the string. The string can be specified as "toto", "tata", "titi" @param string $value @return array<string>
[ "Returns", "a", "list", "from", "the", "string", ".", "The", "string", "can", "be", "specified", "as", "toto", "tata", "titi" ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/MoufAnnotationHelper.php#L24-L37
train
thecodingmachine/mouf
src/Mouf/MoufPropertyDescriptor.php
MoufPropertyDescriptor.getPropertyNameFromSetterName
public static function getPropertyNameFromSetterName($methodName) { if (strpos($methodName, "set") !== 0) { throw new MoufException("Error while creating MoufPropertyDescriptor. A @Property annotation must be set to methods that start with 'set'. For instance: setName, and setPhone are valid @Property setters. $methodName is not a valid setter name."); } $propName1 = substr($methodName, 3); if (empty($propName1)) { throw new MoufException("Error while creating MoufPropertyDescriptor. A @Property annotation cannot be put on a method named 'set'. It must be put on a method whose name starts with 'set'. For instance: setName, and setPhone are valid @Property setters."); } $propName2 = strtolower(substr($propName1,0,1)).substr($propName1,1); return $propName2; }
php
public static function getPropertyNameFromSetterName($methodName) { if (strpos($methodName, "set") !== 0) { throw new MoufException("Error while creating MoufPropertyDescriptor. A @Property annotation must be set to methods that start with 'set'. For instance: setName, and setPhone are valid @Property setters. $methodName is not a valid setter name."); } $propName1 = substr($methodName, 3); if (empty($propName1)) { throw new MoufException("Error while creating MoufPropertyDescriptor. A @Property annotation cannot be put on a method named 'set'. It must be put on a method whose name starts with 'set'. For instance: setName, and setPhone are valid @Property setters."); } $propName2 = strtolower(substr($propName1,0,1)).substr($propName1,1); return $propName2; }
[ "public", "static", "function", "getPropertyNameFromSetterName", "(", "$", "methodName", ")", "{", "if", "(", "strpos", "(", "$", "methodName", ",", "\"set\"", ")", "!==", "0", ")", "{", "throw", "new", "MoufException", "(", "\"Error while creating MoufPropertyDes...
Transforms the setter name in a property name. For instance, getPhone => phone or getName => name @param string $methodName @return string
[ "Transforms", "the", "setter", "name", "in", "a", "property", "name", ".", "For", "instance", "getPhone", "=", ">", "phone", "or", "getName", "=", ">", "name" ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufPropertyDescriptor.php#L290-L300
train
thecodingmachine/mouf
src/Mouf/Reflection/MoufReflectionMethod.php
MoufReflectionMethod.getDeclaringClass
public function getDeclaringClass() { if ($this->declaringClass) { return $this->declaringClass; } $methodFile = $this->getFileName(); $methodStartLine = $this->getStartLine(); $methodEndLine = $this->getEndLine(); $oldDeclaringClass = $this->getDeclaringClassWithoutTraits(); // Let's scan all traits $trait = $this->deepScanTraits($oldDeclaringClass->getTraits(), $methodFile, $methodStartLine, $methodEndLine); if ($trait != null) { $this->declaringClass = $trait; return $trait; } else { $this->declaringClass = $oldDeclaringClass; return $oldDeclaringClass; } }
php
public function getDeclaringClass() { if ($this->declaringClass) { return $this->declaringClass; } $methodFile = $this->getFileName(); $methodStartLine = $this->getStartLine(); $methodEndLine = $this->getEndLine(); $oldDeclaringClass = $this->getDeclaringClassWithoutTraits(); // Let's scan all traits $trait = $this->deepScanTraits($oldDeclaringClass->getTraits(), $methodFile, $methodStartLine, $methodEndLine); if ($trait != null) { $this->declaringClass = $trait; return $trait; } else { $this->declaringClass = $oldDeclaringClass; return $oldDeclaringClass; } }
[ "public", "function", "getDeclaringClass", "(", ")", "{", "if", "(", "$", "this", "->", "declaringClass", ")", "{", "return", "$", "this", "->", "declaringClass", ";", "}", "$", "methodFile", "=", "$", "this", "->", "getFileName", "(", ")", ";", "$", "...
returns the class that declares this method @return MoufReflectionClass
[ "returns", "the", "class", "that", "declares", "this", "method" ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/MoufReflectionMethod.php#L154-L175
train
thecodingmachine/mouf
src/Mouf/Reflection/MoufReflectionMethod.php
MoufReflectionMethod.toXml
public function toXml(\SimpleXmlElement $root) { $methodNode = $root->addChild("method"); $methodNode->addAttribute("name", $this->getName()); $modifier = ""; if ($this->isPublic()) { $modifier = "public"; } elseif ($this->isProtected()) { $modifier = "protected"; } elseif ($this->isPrivate()) { $modifier = "private"; } $methodNode->addAttribute("modifier", $modifier); $methodNode->addAttribute("static", $this->isStatic()?"true":"false"); $methodNode->addAttribute("abstract", $this->isAbstract()?"true":"false"); $methodNode->addAttribute("constructor", $this->isConstructor()?"true":"false"); $methodNode->addAttribute("final", $this->isFinal()?"true":"false"); $commentNode = $methodNode->addChild("comment"); $node= dom_import_simplexml($commentNode); $no = $node->ownerDocument; $node->appendChild($no->createCDATASection($this->getDocComment())); foreach ($this->getParameters() as $parameter) { $parameter->toXml($methodNode); } }
php
public function toXml(\SimpleXmlElement $root) { $methodNode = $root->addChild("method"); $methodNode->addAttribute("name", $this->getName()); $modifier = ""; if ($this->isPublic()) { $modifier = "public"; } elseif ($this->isProtected()) { $modifier = "protected"; } elseif ($this->isPrivate()) { $modifier = "private"; } $methodNode->addAttribute("modifier", $modifier); $methodNode->addAttribute("static", $this->isStatic()?"true":"false"); $methodNode->addAttribute("abstract", $this->isAbstract()?"true":"false"); $methodNode->addAttribute("constructor", $this->isConstructor()?"true":"false"); $methodNode->addAttribute("final", $this->isFinal()?"true":"false"); $commentNode = $methodNode->addChild("comment"); $node= dom_import_simplexml($commentNode); $no = $node->ownerDocument; $node->appendChild($no->createCDATASection($this->getDocComment())); foreach ($this->getParameters() as $parameter) { $parameter->toXml($methodNode); } }
[ "public", "function", "toXml", "(", "\\", "SimpleXmlElement", "$", "root", ")", "{", "$", "methodNode", "=", "$", "root", "->", "addChild", "(", "\"method\"", ")", ";", "$", "methodNode", "->", "addAttribute", "(", "\"name\"", ",", "$", "this", "->", "ge...
Appends this method to the XML node passed in parameter. @param SimpleXmlElement $root The root XML node the method will be appended to.
[ "Appends", "this", "method", "to", "the", "XML", "node", "passed", "in", "parameter", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/MoufReflectionMethod.php#L251-L277
train
thecodingmachine/mouf
src/Mouf/Reflection/MoufReflectionMethod.php
MoufReflectionMethod.toJson
public function toJson() { $result = array(); $result['name'] = $this->getName(); $modifier = ""; if ($this->isPublic()) { $modifier = "public"; } elseif ($this->isProtected()) { $modifier = "protected"; } elseif ($this->isPrivate()) { $modifier = "private"; } $result['modifier'] = $modifier; $result['static'] = $this->isStatic(); $result['abstract'] = $this->isAbstract(); $result['constructor'] = $this->isConstructor(); $result['final'] = $this->isFinal(); //$result['comment'] = $this->getDocComment(); $result['comment'] = $this->getMoufPhpDocComment()->getJsonArray(); $result['parameters'] = array(); $parameters = $this->getParameters(); foreach ($parameters as $parameter) { $result['parameters'][] = $parameter->toJson(); } //$properties = $this->getAnnotations("Property"); try { /*if (!empty($properties)) { $result['moufProperty'] = true;*/ // TODO: is there a need to instanciate a MoufPropertyDescriptor? // If this is a setter only: if ($this->isSetter()) { $moufPropertyDescriptor = new MoufPropertyDescriptor($this); $types = $moufPropertyDescriptor->getTypes(); $result['types'] = $types->toJson(); if ($types->getWarningMessage()) { $result['classinerror'] = $types->getWarningMessage(); } } /*if ($moufPropertyDescriptor->isAssociativeArray()) { $result['keytype'] = $moufPropertyDescriptor->getKeyType(); } if ($moufPropertyDescriptor->isArray()) { $result['subtype'] = $moufPropertyDescriptor->getSubType(); }*/ //} } catch (\Exception $e) { $result['classinerror'] = $e->getMessage(); } return $result; }
php
public function toJson() { $result = array(); $result['name'] = $this->getName(); $modifier = ""; if ($this->isPublic()) { $modifier = "public"; } elseif ($this->isProtected()) { $modifier = "protected"; } elseif ($this->isPrivate()) { $modifier = "private"; } $result['modifier'] = $modifier; $result['static'] = $this->isStatic(); $result['abstract'] = $this->isAbstract(); $result['constructor'] = $this->isConstructor(); $result['final'] = $this->isFinal(); //$result['comment'] = $this->getDocComment(); $result['comment'] = $this->getMoufPhpDocComment()->getJsonArray(); $result['parameters'] = array(); $parameters = $this->getParameters(); foreach ($parameters as $parameter) { $result['parameters'][] = $parameter->toJson(); } //$properties = $this->getAnnotations("Property"); try { /*if (!empty($properties)) { $result['moufProperty'] = true;*/ // TODO: is there a need to instanciate a MoufPropertyDescriptor? // If this is a setter only: if ($this->isSetter()) { $moufPropertyDescriptor = new MoufPropertyDescriptor($this); $types = $moufPropertyDescriptor->getTypes(); $result['types'] = $types->toJson(); if ($types->getWarningMessage()) { $result['classinerror'] = $types->getWarningMessage(); } } /*if ($moufPropertyDescriptor->isAssociativeArray()) { $result['keytype'] = $moufPropertyDescriptor->getKeyType(); } if ($moufPropertyDescriptor->isArray()) { $result['subtype'] = $moufPropertyDescriptor->getSubType(); }*/ //} } catch (\Exception $e) { $result['classinerror'] = $e->getMessage(); } return $result; }
[ "public", "function", "toJson", "(", ")", "{", "$", "result", "=", "array", "(", ")", ";", "$", "result", "[", "'name'", "]", "=", "$", "this", "->", "getName", "(", ")", ";", "$", "modifier", "=", "\"\"", ";", "if", "(", "$", "this", "->", "is...
Returns a PHP array representing the method. @return array
[ "Returns", "a", "PHP", "array", "representing", "the", "method", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/MoufReflectionMethod.php#L284-L342
train
thecodingmachine/mouf
src/Mouf/Reflection/MoufReflectionMethod.php
MoufReflectionMethod.isSetter
public function isSetter() { $methodName = $this->getName(); if (strpos($methodName, "set") === 0 && strlen($methodName)>3) { // A setter must have exactly one compulsory parameter $parameters = $this->getParameters(); if (count($parameters) == 0) { return false; } if (count($parameters)>1) { for ($i=1, $count=count($parameters); $i<$count; $i++) { $param = $parameters[$i]; if (!$param->isDefaultValueAvailable()) { return false; } } } return true; } return false; }
php
public function isSetter() { $methodName = $this->getName(); if (strpos($methodName, "set") === 0 && strlen($methodName)>3) { // A setter must have exactly one compulsory parameter $parameters = $this->getParameters(); if (count($parameters) == 0) { return false; } if (count($parameters)>1) { for ($i=1, $count=count($parameters); $i<$count; $i++) { $param = $parameters[$i]; if (!$param->isDefaultValueAvailable()) { return false; } } } return true; } return false; }
[ "public", "function", "isSetter", "(", ")", "{", "$", "methodName", "=", "$", "this", "->", "getName", "(", ")", ";", "if", "(", "strpos", "(", "$", "methodName", ",", "\"set\"", ")", "===", "0", "&&", "strlen", "(", "$", "methodName", ")", ">", "3...
Returns true if this method has the signature of a setter. @return boolean
[ "Returns", "true", "if", "this", "method", "has", "the", "signature", "of", "a", "setter", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/MoufReflectionMethod.php#L349-L371
train
thecodingmachine/mouf
src/Mouf/CodeValidatorService.php
CodeValidatorService.validateCode
public static function validateCode($codeString) { $code = "<?php \$a = function(ContainerInterface \$container) { ".$codeString."\n}\n?>"; $parser = (new ParserFactory())->create(ParserFactory::PREFER_PHP7); $stmts = $parser->parse($code); // If we are here, the code is correct. // Let's add a last check: whether there is a "return" keyword or not. if (stripos($code, "return") === false) { throw new Error("Missing 'return' keyword.", count(explode("\n", $codeString))); } }
php
public static function validateCode($codeString) { $code = "<?php \$a = function(ContainerInterface \$container) { ".$codeString."\n}\n?>"; $parser = (new ParserFactory())->create(ParserFactory::PREFER_PHP7); $stmts = $parser->parse($code); // If we are here, the code is correct. // Let's add a last check: whether there is a "return" keyword or not. if (stripos($code, "return") === false) { throw new Error("Missing 'return' keyword.", count(explode("\n", $codeString))); } }
[ "public", "static", "function", "validateCode", "(", "$", "codeString", ")", "{", "$", "code", "=", "\"<?php \\$a = function(ContainerInterface \\$container) { \"", ".", "$", "codeString", ".", "\"\\n}\\n?>\"", ";", "$", "parser", "=", "(", "new", "ParserFactory", "...
This function will throw a PhpParser\Error exception if a parsing error is met in the code. @param string $codeString @throws \PhpParser\Error
[ "This", "function", "will", "throw", "a", "PhpParser", "\\", "Error", "exception", "if", "a", "parsing", "error", "is", "met", "in", "the", "code", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/CodeValidatorService.php#L32-L44
train
thecodingmachine/mouf
src/Mouf/Moufspector.php
Moufspector.getComponentsList
public static function getComponentsList($type = null, $selfEdit = false) { //$composerService = new ComposerService($selfEdit); $moufClassExplorer = new MoufClassExplorer($selfEdit); $classesList = array_keys($moufClassExplorer->getClassMap()); // Let's add the list of PHP inner classes. $innerClasses = get_declared_classes(); $classesList = array_merge($classesList, $innerClasses); $classesList = array_flip(array_flip($classesList)); //$classesList = get_declared_classes(); $componentsList = array(); foreach ($classesList as $className) { $refClass = new MoufReflectionClass($className); if ($refClass->isInstantiable()) { if ($type == null) { $componentsList[] = $className; } else { try { if ($refClass->implementsInterface($type)) { $componentsList[] = $className; continue; } } catch (\ReflectionException $e) { // The interface might not exist, that's not a problem } try { if ($refClass->isSubclassOf($type)) { $componentsList[] = $className; continue; } } catch (\ReflectionException $e) { // The class might not exist, that's not a problem } if ($refClass->getName() == $type) { $componentsList[] = $className; } } } } return $componentsList; }
php
public static function getComponentsList($type = null, $selfEdit = false) { //$composerService = new ComposerService($selfEdit); $moufClassExplorer = new MoufClassExplorer($selfEdit); $classesList = array_keys($moufClassExplorer->getClassMap()); // Let's add the list of PHP inner classes. $innerClasses = get_declared_classes(); $classesList = array_merge($classesList, $innerClasses); $classesList = array_flip(array_flip($classesList)); //$classesList = get_declared_classes(); $componentsList = array(); foreach ($classesList as $className) { $refClass = new MoufReflectionClass($className); if ($refClass->isInstantiable()) { if ($type == null) { $componentsList[] = $className; } else { try { if ($refClass->implementsInterface($type)) { $componentsList[] = $className; continue; } } catch (\ReflectionException $e) { // The interface might not exist, that's not a problem } try { if ($refClass->isSubclassOf($type)) { $componentsList[] = $className; continue; } } catch (\ReflectionException $e) { // The class might not exist, that's not a problem } if ($refClass->getName() == $type) { $componentsList[] = $className; } } } } return $componentsList; }
[ "public", "static", "function", "getComponentsList", "(", "$", "type", "=", "null", ",", "$", "selfEdit", "=", "false", ")", "{", "//$composerService = new ComposerService($selfEdit);\r", "$", "moufClassExplorer", "=", "new", "MoufClassExplorer", "(", "$", "selfEdit",...
Returns a list of all the classes, or only classes inheriting the passed class or interface. Classes that can't be instanciated are excluded from the list. @type string the class or interface the class must inherit to be part of the list. If not passed, all classes are returned. @return array<string>
[ "Returns", "a", "list", "of", "all", "the", "classes", "or", "only", "classes", "inheriting", "the", "passed", "class", "or", "interface", ".", "Classes", "that", "can", "t", "be", "instanciated", "are", "excluded", "from", "the", "list", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Moufspector.php#L31-L75
train
thecodingmachine/mouf
src/Mouf/MoufClassExplorer.php
MoufClassExplorer.getClassMap
public function getClassMap() { if ($this->classMap) { return $this->classMap; } if ($this->useCache) { // Cache duration: 30 minutes. $this->classMap = $this->cacheService->get("mouf.classMap.".__DIR__."/".json_encode($this->selfEdit)); if ($this->classMap != null) { return $this->classMap; } } $this->analyze(); return $this->classMap; }
php
public function getClassMap() { if ($this->classMap) { return $this->classMap; } if ($this->useCache) { // Cache duration: 30 minutes. $this->classMap = $this->cacheService->get("mouf.classMap.".__DIR__."/".json_encode($this->selfEdit)); if ($this->classMap != null) { return $this->classMap; } } $this->analyze(); return $this->classMap; }
[ "public", "function", "getClassMap", "(", ")", "{", "if", "(", "$", "this", "->", "classMap", ")", "{", "return", "$", "this", "->", "classMap", ";", "}", "if", "(", "$", "this", "->", "useCache", ")", "{", "// Cache duration: 30 minutes.\r", "$", "this"...
Returns the classmap of all available and safe to include classes. @return array<string, string>
[ "Returns", "the", "classmap", "of", "all", "available", "and", "safe", "to", "include", "classes", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufClassExplorer.php#L231-L246
train
thecodingmachine/mouf
src/Mouf/MoufClassExplorer.php
MoufClassExplorer.getErrors
public function getErrors() { if ($this->forbiddenClasses) { return $this->forbiddenClasses; } if ($this->useCache) { // Cache duration: 30 minutes. $this->forbiddenClasses = $this->cacheService->get("forbidden.classes.".__DIR__."/".json_encode($this->selfEdit)); if ($this->forbiddenClasses != null) { return $this->forbiddenClasses; } } $this->analyze(); return $this->forbiddenClasses; }
php
public function getErrors() { if ($this->forbiddenClasses) { return $this->forbiddenClasses; } if ($this->useCache) { // Cache duration: 30 minutes. $this->forbiddenClasses = $this->cacheService->get("forbidden.classes.".__DIR__."/".json_encode($this->selfEdit)); if ($this->forbiddenClasses != null) { return $this->forbiddenClasses; } } $this->analyze(); return $this->forbiddenClasses; }
[ "public", "function", "getErrors", "(", ")", "{", "if", "(", "$", "this", "->", "forbiddenClasses", ")", "{", "return", "$", "this", "->", "forbiddenClasses", ";", "}", "if", "(", "$", "this", "->", "useCache", ")", "{", "// Cache duration: 30 minutes.\r", ...
Returns the array of all classes that have problems to be included, along the error associated. The key is the filename, the value the error message outputed. @return array<string, string>
[ "Returns", "the", "array", "of", "all", "classes", "that", "have", "problems", "to", "be", "included", "along", "the", "error", "associated", ".", "The", "key", "is", "the", "filename", "the", "value", "the", "error", "message", "outputed", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufClassExplorer.php#L253-L268
train
thecodingmachine/mouf
src/Mouf/MoufUtils.php
MoufUtils.registerChooseInstanceMenuItem
public static function registerChooseInstanceMenuItem($instanceName, $label, $url, $type, $parentMenuItemName = 'moufSubMenu', $priority = 50) { $moufManager = MoufManager::getMoufManager(); if ($moufManager->instanceExists($instanceName)) { return; } $moufManager->declareComponent($instanceName, 'Mouf\\Menu\\ChooseInstanceMenuItem', true); $moufManager->setParameterViaSetter($instanceName, 'setLabel', $label); $moufManager->setParameterViaSetter($instanceName, 'setUrl', $url); $moufManager->setParameterViaSetter($instanceName, 'setType', $type); $moufManager->setParameterViaSetter($instanceName, 'setPriority', $priority); $parentMenuItem = MoufManager::getMoufManager()->getInstance($parentMenuItemName); /* @var $parentMenuItem MenuItem */ $parentMenuItem->addMenuItem(MoufManager::getMoufManager()->getInstance($instanceName)); }
php
public static function registerChooseInstanceMenuItem($instanceName, $label, $url, $type, $parentMenuItemName = 'moufSubMenu', $priority = 50) { $moufManager = MoufManager::getMoufManager(); if ($moufManager->instanceExists($instanceName)) { return; } $moufManager->declareComponent($instanceName, 'Mouf\\Menu\\ChooseInstanceMenuItem', true); $moufManager->setParameterViaSetter($instanceName, 'setLabel', $label); $moufManager->setParameterViaSetter($instanceName, 'setUrl', $url); $moufManager->setParameterViaSetter($instanceName, 'setType', $type); $moufManager->setParameterViaSetter($instanceName, 'setPriority', $priority); $parentMenuItem = MoufManager::getMoufManager()->getInstance($parentMenuItemName); /* @var $parentMenuItem MenuItem */ $parentMenuItem->addMenuItem(MoufManager::getMoufManager()->getInstance($instanceName)); }
[ "public", "static", "function", "registerChooseInstanceMenuItem", "(", "$", "instanceName", ",", "$", "label", ",", "$", "url", ",", "$", "type", ",", "$", "parentMenuItemName", "=", "'moufSubMenu'", ",", "$", "priority", "=", "50", ")", "{", "$", "moufManag...
Registers a new menuItem instance to be displayed in Mouf main menu that triggers a popup to choose an instance. @param string $instanceName @param string $label @param string $url @param string $type @param string $parentMenuItemName The parent menu item instance name. 'mainMenu' is the main menu item, and 'moufSubMenu' is the 'Mouf' menu @param float $priority The position of the menu
[ "Registers", "a", "new", "menuItem", "instance", "to", "be", "displayed", "in", "Mouf", "main", "menu", "that", "triggers", "a", "popup", "to", "choose", "an", "instance", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufUtils.php#L93-L109
train
thecodingmachine/mouf
src/Mouf/MoufConfigManager.php
MoufConfigManager.getMergedConstants
public function getMergedConstants() { $constantsInConfig = $this->getDefinedConstants(); $finalArr = $this->constantsDef; foreach ($finalArr as $name => $constantDef) { if (isset($constantsInConfig[$name])) { $finalArr[$name]["value"] = $constantsInConfig[$name]; unset($constantsInConfig[$name]); } else { $finalArr[$name]["missinginconfigphp"] = true; } $finalArr[$name]["defined"] = true; } // Now, let's add the defined constant that have no definition in MoufComponents foreach ($constantsInConfig as $name=>$value) { $finalArr[$name] = array("value"=>$value, "defined"=>false); } return $finalArr; }
php
public function getMergedConstants() { $constantsInConfig = $this->getDefinedConstants(); $finalArr = $this->constantsDef; foreach ($finalArr as $name => $constantDef) { if (isset($constantsInConfig[$name])) { $finalArr[$name]["value"] = $constantsInConfig[$name]; unset($constantsInConfig[$name]); } else { $finalArr[$name]["missinginconfigphp"] = true; } $finalArr[$name]["defined"] = true; } // Now, let's add the defined constant that have no definition in MoufComponents foreach ($constantsInConfig as $name=>$value) { $finalArr[$name] = array("value"=>$value, "defined"=>false); } return $finalArr; }
[ "public", "function", "getMergedConstants", "(", ")", "{", "$", "constantsInConfig", "=", "$", "this", "->", "getDefinedConstants", "(", ")", ";", "$", "finalArr", "=", "$", "this", "->", "constantsDef", ";", "foreach", "(", "$", "finalArr", "as", "$", "na...
This function returns an array of all constants, with there attributes. It merges the constants definitions defined in MoufComponents and the constants defined in config.php. The returned values are in this format: $array["constantName"] = array("defaultValue"=>"", "type"=>"string|int|float|bool", "comment"=>"some comment", "value"=>"", "defined"=>true|false, "missinginconfigphp"=>true|notdefined, , "fetchFromEnv"=>true|false); return array
[ "This", "function", "returns", "an", "array", "of", "all", "constants", "with", "there", "attributes", ".", "It", "merges", "the", "constants", "definitions", "defined", "in", "MoufComponents", "and", "the", "constants", "defined", "in", "config", ".", "php", ...
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufConfigManager.php#L191-L211
train
thecodingmachine/mouf
src/Mouf/MoufInstancePropertyDescriptor.php
MoufInstancePropertyDescriptor.toInstanceDescriptor
private function toInstanceDescriptor($instanceNames) { if ($instanceNames === null) { return null; } if (is_array($instanceNames)) { $moufManager = $this->moufManager; return self::array_map_deep($instanceNames, function($instanceName) use ($moufManager) { if ($instanceName != null) { return $moufManager->getInstanceDescriptor($instanceName); } else { return null; } }); /*$arrayOfDescriptors = array(); foreach ($instanceNames as $key=>$instanceName) { if ($instanceName != null) { $arrayOfDescriptors[$key] = $this->moufManager->getInstanceDescriptor($instanceName); } else { $arrayOfDescriptors[$key] = null; } } return $arrayOfDescriptors;*/ } else { return $this->moufManager->getInstanceDescriptor($instanceNames); } }
php
private function toInstanceDescriptor($instanceNames) { if ($instanceNames === null) { return null; } if (is_array($instanceNames)) { $moufManager = $this->moufManager; return self::array_map_deep($instanceNames, function($instanceName) use ($moufManager) { if ($instanceName != null) { return $moufManager->getInstanceDescriptor($instanceName); } else { return null; } }); /*$arrayOfDescriptors = array(); foreach ($instanceNames as $key=>$instanceName) { if ($instanceName != null) { $arrayOfDescriptors[$key] = $this->moufManager->getInstanceDescriptor($instanceName); } else { $arrayOfDescriptors[$key] = null; } } return $arrayOfDescriptors;*/ } else { return $this->moufManager->getInstanceDescriptor($instanceNames); } }
[ "private", "function", "toInstanceDescriptor", "(", "$", "instanceNames", ")", "{", "if", "(", "$", "instanceNames", "===", "null", ")", "{", "return", "null", ";", "}", "if", "(", "is_array", "(", "$", "instanceNames", ")", ")", "{", "$", "moufManager", ...
Takes in parameter a return from the getBoundComponentsXXX methods and cast that to a MoufInstanceDescriptor or an array of MoufInstanceDescriptor. @param string[]|string $instanceNames @return NULL|multitype:NULL Ambigous <\Mouf\MoufInstanceDescriptor, \Mouf\array<string,> |Ambigous <\Mouf\MoufInstanceDescriptor, \Mouf\array<string,>
[ "Takes", "in", "parameter", "a", "return", "from", "the", "getBoundComponentsXXX", "methods", "and", "cast", "that", "to", "a", "MoufInstanceDescriptor", "or", "an", "array", "of", "MoufInstanceDescriptor", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufInstancePropertyDescriptor.php#L175-L201
train
thecodingmachine/mouf
src/Mouf/MoufInstancePropertyDescriptor.php
MoufInstancePropertyDescriptor.getValue
public function getValue() { if ($this->propertyDescriptor->isPublicFieldProperty()) { // Let's try to see if it is a "value": $param = $this->moufManager->getParameter($this->instanceDescriptor->getIdentifierName(), $this->name); if ($param !== null) { return $param; } $instanceName = $this->moufManager->getBoundComponentsOnProperty($this->instanceDescriptor->getIdentifierName(), $this->name); return $this->toInstanceDescriptor($instanceName); } elseif ($this->propertyDescriptor->isSetterProperty()) { // Let's try to see if it is a "value": $param = $this->moufManager->getParameterForSetter($this->instanceDescriptor->getIdentifierName(), $this->name); if ($param !== null) { return $param; } $instanceName = $this->moufManager->getBoundComponentsOnSetter($this->instanceDescriptor->getIdentifierName(), $this->name); return $this->toInstanceDescriptor($instanceName); } elseif ($this->propertyDescriptor->isConstructor()) { // Let's try to see if it is a "value": $argumentType = $this->moufManager->isConstructorParameterObjectOrPrimitive($this->instanceDescriptor->getIdentifierName(), $this->propertyDescriptor->getParameterIndex()); $param = $this->moufManager->getParameterForConstructor($this->instanceDescriptor->getIdentifierName(), $this->propertyDescriptor->getParameterIndex()); if ($argumentType == "primitive") { return $param; } elseif ($argumentType == "object") { return $this->toInstanceDescriptor($param); } else { // Not set: return null return null; } } else { throw new MoufException("Unsupported property type: it is not a public field nor a setter nor a constructor..."); } }
php
public function getValue() { if ($this->propertyDescriptor->isPublicFieldProperty()) { // Let's try to see if it is a "value": $param = $this->moufManager->getParameter($this->instanceDescriptor->getIdentifierName(), $this->name); if ($param !== null) { return $param; } $instanceName = $this->moufManager->getBoundComponentsOnProperty($this->instanceDescriptor->getIdentifierName(), $this->name); return $this->toInstanceDescriptor($instanceName); } elseif ($this->propertyDescriptor->isSetterProperty()) { // Let's try to see if it is a "value": $param = $this->moufManager->getParameterForSetter($this->instanceDescriptor->getIdentifierName(), $this->name); if ($param !== null) { return $param; } $instanceName = $this->moufManager->getBoundComponentsOnSetter($this->instanceDescriptor->getIdentifierName(), $this->name); return $this->toInstanceDescriptor($instanceName); } elseif ($this->propertyDescriptor->isConstructor()) { // Let's try to see if it is a "value": $argumentType = $this->moufManager->isConstructorParameterObjectOrPrimitive($this->instanceDescriptor->getIdentifierName(), $this->propertyDescriptor->getParameterIndex()); $param = $this->moufManager->getParameterForConstructor($this->instanceDescriptor->getIdentifierName(), $this->propertyDescriptor->getParameterIndex()); if ($argumentType == "primitive") { return $param; } elseif ($argumentType == "object") { return $this->toInstanceDescriptor($param); } else { // Not set: return null return null; } } else { throw new MoufException("Unsupported property type: it is not a public field nor a setter nor a constructor..."); } }
[ "public", "function", "getValue", "(", ")", "{", "if", "(", "$", "this", "->", "propertyDescriptor", "->", "isPublicFieldProperty", "(", ")", ")", "{", "// Let's try to see if it is a \"value\":", "$", "param", "=", "$", "this", "->", "moufManager", "->", "getPa...
Returns the value for this property. The value returned can be a primitive type, an array of primitive types, a MoufInstanceDescriptor or an array of MoufInstanceDescriptors, depending on the type of the parameter. @return string|MoufInstanceDescriptor|null
[ "Returns", "the", "value", "for", "this", "property", ".", "The", "value", "returned", "can", "be", "a", "primitive", "type", "an", "array", "of", "primitive", "types", "a", "MoufInstanceDescriptor", "or", "an", "array", "of", "MoufInstanceDescriptors", "dependi...
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufInstancePropertyDescriptor.php#L222-L263
train
thecodingmachine/mouf
src/Mouf/MoufInstancePropertyDescriptor.php
MoufInstancePropertyDescriptor.getMetaData
public function getMetaData() { if ($this->propertyDescriptor->isPublicFieldProperty()) { return $this->moufManager->getParameterMetadata($this->instanceDescriptor->getIdentifierName(), $this->name); } elseif ($this->propertyDescriptor->isSetterProperty()) { return $this->moufManager->getParameterMetadataForSetter($this->instanceDescriptor->getIdentifierName(), $this->name); } elseif ($this->propertyDescriptor->isConstructor()) { return $this->moufManager->getParameterMetadataForConstructor($this->instanceDescriptor->getIdentifierName(), $this->propertyDescriptor->getParameterIndex()); } else { throw new MoufException("Unsupported property type: it is not a public field nor a setter nor a constructor..."); } }
php
public function getMetaData() { if ($this->propertyDescriptor->isPublicFieldProperty()) { return $this->moufManager->getParameterMetadata($this->instanceDescriptor->getIdentifierName(), $this->name); } elseif ($this->propertyDescriptor->isSetterProperty()) { return $this->moufManager->getParameterMetadataForSetter($this->instanceDescriptor->getIdentifierName(), $this->name); } elseif ($this->propertyDescriptor->isConstructor()) { return $this->moufManager->getParameterMetadataForConstructor($this->instanceDescriptor->getIdentifierName(), $this->propertyDescriptor->getParameterIndex()); } else { throw new MoufException("Unsupported property type: it is not a public field nor a setter nor a constructor..."); } }
[ "public", "function", "getMetaData", "(", ")", "{", "if", "(", "$", "this", "->", "propertyDescriptor", "->", "isPublicFieldProperty", "(", ")", ")", "{", "return", "$", "this", "->", "moufManager", "->", "getParameterMetadata", "(", "$", "this", "->", "inst...
Returns metadata for this property @return string
[ "Returns", "metadata", "for", "this", "property" ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufInstancePropertyDescriptor.php#L329-L339
train
thecodingmachine/mouf
src/Mouf/MoufInstancePropertyDescriptor.php
MoufInstancePropertyDescriptor.toJson
public function toJson() { $result = array(); $value = $this->getValue(); if ($value instanceof MoufInstanceDescriptor) { $serializableValue = $value->getIdentifierName(); //$result['type'] = 'object'; } elseif (is_array($value)) { // We cannot match a PHP array to a JSON array! // The keys in a PHP array are ordered. The key in a JSON array are not ordered! // Therefore, we will be sending the arrays as JSON arrays of key/values to preserve order. $serializableValue = self::arrayToJson($value); //$result['type'] = 'scalar'; // Let's find the type: /*foreach ($value as $val) { if ($val instanceof MoufInstanceDescriptor) { //$result['type'] = 'object'; break; } }*/ } else { $serializableValue = $value; //$result['type'] = 'scalar'; } try { $type = $this->propertyDescriptor->getTypes()->getCompatibleTypeForInstance($value); } catch (\ReflectionException $e) { // If an error occurs here, let's silently continue with an error message added. $result['warning'] = $e->getMessage(); $type = null; } /*if ($type == null) { throw new MoufException("Error for property ".$this->propertyDescriptor->getName()." for instance ".$this->instanceDescriptor->getName()."."); }*/ if ($type == null) { $result['type'] = null; } else { $result['type'] = $type->toJson(); } $result['value'] = $serializableValue; $result['isset'] = $this->isValueSet(); $result['origin'] = $this->getOrigin(); $result['metadata'] = $this->getMetaData(); return $result; }
php
public function toJson() { $result = array(); $value = $this->getValue(); if ($value instanceof MoufInstanceDescriptor) { $serializableValue = $value->getIdentifierName(); //$result['type'] = 'object'; } elseif (is_array($value)) { // We cannot match a PHP array to a JSON array! // The keys in a PHP array are ordered. The key in a JSON array are not ordered! // Therefore, we will be sending the arrays as JSON arrays of key/values to preserve order. $serializableValue = self::arrayToJson($value); //$result['type'] = 'scalar'; // Let's find the type: /*foreach ($value as $val) { if ($val instanceof MoufInstanceDescriptor) { //$result['type'] = 'object'; break; } }*/ } else { $serializableValue = $value; //$result['type'] = 'scalar'; } try { $type = $this->propertyDescriptor->getTypes()->getCompatibleTypeForInstance($value); } catch (\ReflectionException $e) { // If an error occurs here, let's silently continue with an error message added. $result['warning'] = $e->getMessage(); $type = null; } /*if ($type == null) { throw new MoufException("Error for property ".$this->propertyDescriptor->getName()." for instance ".$this->instanceDescriptor->getName()."."); }*/ if ($type == null) { $result['type'] = null; } else { $result['type'] = $type->toJson(); } $result['value'] = $serializableValue; $result['isset'] = $this->isValueSet(); $result['origin'] = $this->getOrigin(); $result['metadata'] = $this->getMetaData(); return $result; }
[ "public", "function", "toJson", "(", ")", "{", "$", "result", "=", "array", "(", ")", ";", "$", "value", "=", "$", "this", "->", "getValue", "(", ")", ";", "if", "(", "$", "value", "instanceof", "MoufInstanceDescriptor", ")", "{", "$", "serializableVal...
Serializes the mouf instance property into a PHP array @return array
[ "Serializes", "the", "mouf", "instance", "property", "into", "a", "PHP", "array" ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufInstancePropertyDescriptor.php#L409-L456
train
thecodingmachine/mouf
src-dev/Mouf/Controllers/AbstractMoufInstanceController.php
AbstractMoufInstanceController.initController
protected function initController($name, $selfedit) { $this->instanceName = $name; $this->selfedit = $selfedit; /*$this->instance = MoufManager::getMoufManager()->getInstance($name); $this->className = MoufManager::getMoufManager()->getInstanceType($this->instanceName);*/ if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } $this->className = $this->moufManager->getInstanceType($this->instanceName); //$this->reflectionClass = MoufReflectionProxy::getClass($this->className, $selfedit=="true"); $this->weak = $this->moufManager->isInstanceWeak($this->instanceName); // Init the right menu: /*$extendedActions = $this->reflectionClass->getAnnotations("ExtendedAction"); if (!empty($extendedActions)) { $items = array(); foreach ($extendedActions as $extendedAction) { $menuItem = new MenuItem($extendedAction->getName(), ROOT_URL.$extendedAction->getUrl()); $menuItem->setPropagatedUrlParameters(array("selfedit", "name")); $items[] = $menuItem; } $specialActionsMenuItem = new MenuItem("Special actions", null, $items); //$menu = new Menu($items); \MoufAdmin::getSpecialActionsMenu()->addChild($specialActionsMenuItem); //$this->template->addRightHtmlElement($menuItems); }*/ $viewPropertiesMenuItem = new MenuItem("View properties", ROOT_URL."ajaxinstance/"); $viewPropertiesMenuItem->setPropagatedUrlParameters(array("selfedit", "name")); if (!$viewPropertiesMenuItem->isActive()) { // If the view is active, we might as well not display anything! \MoufAdmin::getInstanceMenu()->addChild($viewPropertiesMenuItem); } /*$viewDependencyGraphMenuItem = new MenuItem("View dependency graph", "mouf/displayGraph/"); $viewDependencyGraphMenuItem->setPropagatedUrlParameters(array("selfedit", "name"));*/ //$commonMenuItem = new MenuItem("<b>Common</b>", null, array($viewPropertiesMenuItem/*, $viewDependencyGraphMenuItem*/)); /*$this->template->addRightHtmlElement(new SplashMenu( array( new SplashMenuItem("<b>Common</b>", null, null), new SplashMenuItem("View properties", ROOT_URL."mouf/instance/?name=".$name, null, array("selfedit")), new SplashMenuItem("View dependency graph", "mouf/displayGraph/?name=".$name, null, array("selfedit"))))); $this->template->addRightFunction(array($this, "displayComponentParents")); */ // Let's find the documentation related to this class. // Note: the class name can be null in case of some instances declared via PHP code. if ($this->className) { $cache = new MoufCache(); $documentationMenuItem = $cache->get('documentationMenuForClass_'.$this->className); if ($documentationMenuItem === null) { $documentationMenuItem = new MenuItem("<b>Related documentation</b>"); // TODO: hit the documentation menu instead! if ($this->selfedit == "true") { $composerJsonFiles = DocumentationUtils::getRelatedPackages($this->className); } else { $documentationUtils = new ClassProxy('Mouf\\DocumentationUtils'); $composerJsonFiles = $documentationUtils->getRelatedPackages($this->className); } foreach ($composerJsonFiles as $composerJsonFile) { $parsedJsonFile = json_decode(file_get_contents($composerJsonFile), true); $extra = isset($parsedJsonFile['extra'])?$parsedJsonFile['extra']:array(); $docPages = DocumentationUtils::getDocPages($extra, dirname($composerJsonFile).'/'); if (isset($parsedJsonFile['name']) && $docPages) { $packageName = $parsedJsonFile['name']; $packageDocumentation = new MenuItem($packageName); $documentationMenuItem->addMenuItem($packageDocumentation); DocumentationUtils::fillMenu($packageDocumentation, $docPages, $packageName); } else { // This is probably the root package if it has no name. continue; } } // Short lived cache (3 minutes) $cache->set('documentationMenuForClass_'.$this->className, $documentationMenuItem, 180); } if ($documentationMenuItem->getChildren()) { \MoufAdmin::getInstanceMenu()->addChild($documentationMenuItem); } } //\MoufAdmin::getBlock_left()->addText("<div id='relatedDocumentation'><b>Related documentation:</b>".var_export($composerJsonFiles, true)."</div>"); $this->displayComponentParents(); }
php
protected function initController($name, $selfedit) { $this->instanceName = $name; $this->selfedit = $selfedit; /*$this->instance = MoufManager::getMoufManager()->getInstance($name); $this->className = MoufManager::getMoufManager()->getInstanceType($this->instanceName);*/ if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } $this->className = $this->moufManager->getInstanceType($this->instanceName); //$this->reflectionClass = MoufReflectionProxy::getClass($this->className, $selfedit=="true"); $this->weak = $this->moufManager->isInstanceWeak($this->instanceName); // Init the right menu: /*$extendedActions = $this->reflectionClass->getAnnotations("ExtendedAction"); if (!empty($extendedActions)) { $items = array(); foreach ($extendedActions as $extendedAction) { $menuItem = new MenuItem($extendedAction->getName(), ROOT_URL.$extendedAction->getUrl()); $menuItem->setPropagatedUrlParameters(array("selfedit", "name")); $items[] = $menuItem; } $specialActionsMenuItem = new MenuItem("Special actions", null, $items); //$menu = new Menu($items); \MoufAdmin::getSpecialActionsMenu()->addChild($specialActionsMenuItem); //$this->template->addRightHtmlElement($menuItems); }*/ $viewPropertiesMenuItem = new MenuItem("View properties", ROOT_URL."ajaxinstance/"); $viewPropertiesMenuItem->setPropagatedUrlParameters(array("selfedit", "name")); if (!$viewPropertiesMenuItem->isActive()) { // If the view is active, we might as well not display anything! \MoufAdmin::getInstanceMenu()->addChild($viewPropertiesMenuItem); } /*$viewDependencyGraphMenuItem = new MenuItem("View dependency graph", "mouf/displayGraph/"); $viewDependencyGraphMenuItem->setPropagatedUrlParameters(array("selfedit", "name"));*/ //$commonMenuItem = new MenuItem("<b>Common</b>", null, array($viewPropertiesMenuItem/*, $viewDependencyGraphMenuItem*/)); /*$this->template->addRightHtmlElement(new SplashMenu( array( new SplashMenuItem("<b>Common</b>", null, null), new SplashMenuItem("View properties", ROOT_URL."mouf/instance/?name=".$name, null, array("selfedit")), new SplashMenuItem("View dependency graph", "mouf/displayGraph/?name=".$name, null, array("selfedit"))))); $this->template->addRightFunction(array($this, "displayComponentParents")); */ // Let's find the documentation related to this class. // Note: the class name can be null in case of some instances declared via PHP code. if ($this->className) { $cache = new MoufCache(); $documentationMenuItem = $cache->get('documentationMenuForClass_'.$this->className); if ($documentationMenuItem === null) { $documentationMenuItem = new MenuItem("<b>Related documentation</b>"); // TODO: hit the documentation menu instead! if ($this->selfedit == "true") { $composerJsonFiles = DocumentationUtils::getRelatedPackages($this->className); } else { $documentationUtils = new ClassProxy('Mouf\\DocumentationUtils'); $composerJsonFiles = $documentationUtils->getRelatedPackages($this->className); } foreach ($composerJsonFiles as $composerJsonFile) { $parsedJsonFile = json_decode(file_get_contents($composerJsonFile), true); $extra = isset($parsedJsonFile['extra'])?$parsedJsonFile['extra']:array(); $docPages = DocumentationUtils::getDocPages($extra, dirname($composerJsonFile).'/'); if (isset($parsedJsonFile['name']) && $docPages) { $packageName = $parsedJsonFile['name']; $packageDocumentation = new MenuItem($packageName); $documentationMenuItem->addMenuItem($packageDocumentation); DocumentationUtils::fillMenu($packageDocumentation, $docPages, $packageName); } else { // This is probably the root package if it has no name. continue; } } // Short lived cache (3 minutes) $cache->set('documentationMenuForClass_'.$this->className, $documentationMenuItem, 180); } if ($documentationMenuItem->getChildren()) { \MoufAdmin::getInstanceMenu()->addChild($documentationMenuItem); } } //\MoufAdmin::getBlock_left()->addText("<div id='relatedDocumentation'><b>Related documentation:</b>".var_export($composerJsonFiles, true)."</div>"); $this->displayComponentParents(); }
[ "protected", "function", "initController", "(", "$", "name", ",", "$", "selfedit", ")", "{", "$", "this", "->", "instanceName", "=", "$", "name", ";", "$", "this", "->", "selfedit", "=", "$", "selfedit", ";", "/*$this->instance = MoufManager::getMoufManager()->g...
This function initiates the class variables of the controller according to the parameters passed. It will also configure the template to have the correct entry, especially in the right menu thazt is context dependent. @param string $name the name of the component to display @param string $selfedit If true, the name of the component must be a component from the Mouf framework itself (internal use only)
[ "This", "function", "initiates", "the", "class", "variables", "of", "the", "controller", "according", "to", "the", "parameters", "passed", ".", "It", "will", "also", "configure", "the", "template", "to", "have", "the", "correct", "entry", "especially", "in", "...
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/AbstractMoufInstanceController.php#L88-L190
train
thecodingmachine/mouf
src-dev/Mouf/Controllers/AbstractMoufInstanceController.php
AbstractMoufInstanceController.displayComponentParents
public function displayComponentParents() { $componentsList = $this->moufManager->getOwnerComponents($this->instanceName); $this->canBeWeak = false; if (!empty($componentsList)) { \MoufAdmin::getBlock_left()->addText("<div id='referredInstances'><b>Referred by:</b></div>"); $this->canBeWeak = true; //$children = array(); foreach ($componentsList as $component) { /*$child = new MenuItem($component, ROOT_URL.'ajaxinstance/?name='.urlencode($component)); $child->setPropagatedUrlParameters(array("selfedit")); $children[] = $child;*/ \MoufAdmin::getBlock_left()->addText("<script>MoufInstanceManager.getInstance('".addslashes($component)."').then(function(instance) { instance.render().appendTo(jQuery('#referredInstances')).click(function() { window.location.href=MoufInstanceManager.rootUrl+'ajaxinstance/?name='+encodeURIComponent(instance.getName())+'&selfedit='+MoufInstanceManager.selfEdit; }); });</script>"); } //$referredByMenuItem = new MenuItem('Referred by instances:', null, $children); //\MoufAdmin::getInstanceMenu()->addChild($referredByMenuItem); } }
php
public function displayComponentParents() { $componentsList = $this->moufManager->getOwnerComponents($this->instanceName); $this->canBeWeak = false; if (!empty($componentsList)) { \MoufAdmin::getBlock_left()->addText("<div id='referredInstances'><b>Referred by:</b></div>"); $this->canBeWeak = true; //$children = array(); foreach ($componentsList as $component) { /*$child = new MenuItem($component, ROOT_URL.'ajaxinstance/?name='.urlencode($component)); $child->setPropagatedUrlParameters(array("selfedit")); $children[] = $child;*/ \MoufAdmin::getBlock_left()->addText("<script>MoufInstanceManager.getInstance('".addslashes($component)."').then(function(instance) { instance.render().appendTo(jQuery('#referredInstances')).click(function() { window.location.href=MoufInstanceManager.rootUrl+'ajaxinstance/?name='+encodeURIComponent(instance.getName())+'&selfedit='+MoufInstanceManager.selfEdit; }); });</script>"); } //$referredByMenuItem = new MenuItem('Referred by instances:', null, $children); //\MoufAdmin::getInstanceMenu()->addChild($referredByMenuItem); } }
[ "public", "function", "displayComponentParents", "(", ")", "{", "$", "componentsList", "=", "$", "this", "->", "moufManager", "->", "getOwnerComponents", "(", "$", "this", "->", "instanceName", ")", ";", "$", "this", "->", "canBeWeak", "=", "false", ";", "if...
Displays the list of components directly referencing this component.
[ "Displays", "the", "list", "of", "components", "directly", "referencing", "this", "component", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/AbstractMoufInstanceController.php#L196-L218
train
thecodingmachine/mouf
src-dev/Mouf/Controllers/AbstractMoufInstanceController.php
AbstractMoufInstanceController.getValueForProperty
protected function getValueForProperty(MoufPropertyDescriptor $property) { if ($property->isPublicFieldProperty()) { $propertyName = $property->getName(); if ($this->moufManager->hasParameter($this->instanceName, $propertyName)) { $defaultValue = $this->moufManager->getParameter($this->instanceName, $propertyName); } else { $defaultValue = $this->reflectionClass->getProperty($propertyName)->getDefault(); } } else { // This is a setter. $propertyName = $property->getName(); if ($this->moufManager->hasParameterForSetter($this->instanceName, $property->getMethodName())) { $defaultValue = $this->moufManager->getParameterForSetter($this->instanceName, $property->getMethodName()); } else { // TODO: return a default value. We could try to find it using a getter maybe... // Or a default value for the setter? return null; } } return $defaultValue; }
php
protected function getValueForProperty(MoufPropertyDescriptor $property) { if ($property->isPublicFieldProperty()) { $propertyName = $property->getName(); if ($this->moufManager->hasParameter($this->instanceName, $propertyName)) { $defaultValue = $this->moufManager->getParameter($this->instanceName, $propertyName); } else { $defaultValue = $this->reflectionClass->getProperty($propertyName)->getDefault(); } } else { // This is a setter. $propertyName = $property->getName(); if ($this->moufManager->hasParameterForSetter($this->instanceName, $property->getMethodName())) { $defaultValue = $this->moufManager->getParameterForSetter($this->instanceName, $property->getMethodName()); } else { // TODO: return a default value. We could try to find it using a getter maybe... // Or a default value for the setter? return null; } } return $defaultValue; }
[ "protected", "function", "getValueForProperty", "(", "MoufPropertyDescriptor", "$", "property", ")", "{", "if", "(", "$", "property", "->", "isPublicFieldProperty", "(", ")", ")", "{", "$", "propertyName", "=", "$", "property", "->", "getName", "(", ")", ";", ...
Returns the value set for the instance passed in parameter... or the default value if the value is not set. @param MoufPropertyDescription $property @return mixed
[ "Returns", "the", "value", "set", "for", "the", "instance", "passed", "in", "parameter", "...", "or", "the", "default", "value", "if", "the", "value", "is", "not", "set", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/AbstractMoufInstanceController.php#L226-L247
train
thecodingmachine/mouf
src-dev/Mouf/Controllers/AbstractMoufInstanceController.php
AbstractMoufInstanceController.getTypeForProperty
protected function getTypeForProperty(MoufPropertyDescriptor $property) { if ($property->isPublicFieldProperty()) { $propertyName = $property->getName(); if ($this->moufManager->hasParameter($this->instanceName, $propertyName)) { $defaultValue = $this->moufManager->getParameterType($this->instanceName, $propertyName); } else { return "string"; } } else { // This is a setter. $propertyName = $property->getName(); if ($this->moufManager->hasParameterForSetter($this->instanceName, $property->getMethodName())) { $defaultValue = $this->moufManager->getParameterTypeForSetter($this->instanceName, $property->getMethodName()); } else { return "string"; } } return $defaultValue; }
php
protected function getTypeForProperty(MoufPropertyDescriptor $property) { if ($property->isPublicFieldProperty()) { $propertyName = $property->getName(); if ($this->moufManager->hasParameter($this->instanceName, $propertyName)) { $defaultValue = $this->moufManager->getParameterType($this->instanceName, $propertyName); } else { return "string"; } } else { // This is a setter. $propertyName = $property->getName(); if ($this->moufManager->hasParameterForSetter($this->instanceName, $property->getMethodName())) { $defaultValue = $this->moufManager->getParameterTypeForSetter($this->instanceName, $property->getMethodName()); } else { return "string"; } } return $defaultValue; }
[ "protected", "function", "getTypeForProperty", "(", "MoufPropertyDescriptor", "$", "property", ")", "{", "if", "(", "$", "property", "->", "isPublicFieldProperty", "(", ")", ")", "{", "$", "propertyName", "=", "$", "property", "->", "getName", "(", ")", ";", ...
Returns the type set for the instance passed in parameter. Type is one of string|config|request|session @param MoufPropertyDescription $property @return mixed
[ "Returns", "the", "type", "set", "for", "the", "instance", "passed", "in", "parameter", ".", "Type", "is", "one", "of", "string|config|request|session" ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/AbstractMoufInstanceController.php#L256-L275
train
thecodingmachine/mouf
src-dev/Mouf/Controllers/AbstractMoufInstanceController.php
AbstractMoufInstanceController.getMetadataForProperty
protected function getMetadataForProperty(MoufPropertyDescriptor $property) { if ($property->isPublicFieldProperty()) { $propertyName = $property->getName(); if ($this->moufManager->hasParameter($this->instanceName, $propertyName)) { $defaultValue = $this->moufManager->getParameterMetadata($this->instanceName, $propertyName); } else { return array(); } } else { // This is a setter. $propertyName = $property->getName(); if ($this->moufManager->hasParameterForSetter($this->instanceName, $property->getMethodName())) { $defaultValue = $this->moufManager->getParameterMetadataForSetter($this->instanceName, $property->getMethodName()); } else { return array(); } } return $defaultValue; }
php
protected function getMetadataForProperty(MoufPropertyDescriptor $property) { if ($property->isPublicFieldProperty()) { $propertyName = $property->getName(); if ($this->moufManager->hasParameter($this->instanceName, $propertyName)) { $defaultValue = $this->moufManager->getParameterMetadata($this->instanceName, $propertyName); } else { return array(); } } else { // This is a setter. $propertyName = $property->getName(); if ($this->moufManager->hasParameterForSetter($this->instanceName, $property->getMethodName())) { $defaultValue = $this->moufManager->getParameterMetadataForSetter($this->instanceName, $property->getMethodName()); } else { return array(); } } return $defaultValue; }
[ "protected", "function", "getMetadataForProperty", "(", "MoufPropertyDescriptor", "$", "property", ")", "{", "if", "(", "$", "property", "->", "isPublicFieldProperty", "(", ")", ")", "{", "$", "propertyName", "=", "$", "property", "->", "getName", "(", ")", ";...
Returns the metadata for the instance passed in parameter. @param MoufPropertyDescription $property @return array
[ "Returns", "the", "metadata", "for", "the", "instance", "passed", "in", "parameter", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/AbstractMoufInstanceController.php#L283-L302
train
thecodingmachine/mouf
src-dev/Mouf/Controllers/MoufInstallController.php
MoufInstallController.htaccessNotDetected
public function htaccessNotDetected() { $this->contentBlock->addFile(dirname(__FILE__)."/../../views/mouf_installer/missing_htaccess.php", $this); $this->template->toHtml(); }
php
public function htaccessNotDetected() { $this->contentBlock->addFile(dirname(__FILE__)."/../../views/mouf_installer/missing_htaccess.php", $this); $this->template->toHtml(); }
[ "public", "function", "htaccessNotDetected", "(", ")", "{", "$", "this", "->", "contentBlock", "->", "addFile", "(", "dirname", "(", "__FILE__", ")", ".", "\"/../../views/mouf_installer/missing_htaccess.php\"", ",", "$", "this", ")", ";", "$", "this", "->", "tem...
This page displays an error saying the .htaccess file was ignored by Apache.
[ "This", "page", "displays", "an", "error", "saying", "the", ".", "htaccess", "file", "was", "ignored", "by", "Apache", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/MoufInstallController.php#L76-L80
train
thecodingmachine/mouf
src-dev/Mouf/Controllers/MoufInstallController.php
MoufInstallController.install
public function install() { if (file_exists(__DIR__.'/../../../../../../mouf/no_commit/MoufUsers.php')) { $this->contentBlock->addFile(dirname(__FILE__)."/../../views/mouf_installer/moufusers_exists.php", $this); $this->template->toHtml(); return; } $oldUmask = umask(); umask(0); // Now, let's write the basic Mouf files: if (!file_exists(__DIR__."/../../../../../../mouf")) { mkdir(__DIR__."/../../../../../../mouf", 0775); } if (!file_exists(__DIR__."/../../../../../../mouf/no_commit")) { mkdir(__DIR__."/../../../../../../mouf/no_commit", 0775); } // Write Mouf.php (always): //if (!file_exists(__DIR__."/../../../../../../mouf/Mouf.php")) { $moufStr = "<?php define('ROOT_PATH', realpath(__DIR__.'/..').DIRECTORY_SEPARATOR); require_once __DIR__.'/../config.php'; if (defined('ROOT_URL')) { define('MOUF_URL', ROOT_URL.'vendor/mouf/mouf/'); } require_once __DIR__.'/../vendor/autoload.php'; require_once 'MoufComponents.php'; ?>"; file_put_contents(__DIR__."/../../../../../../mouf/Mouf.php", $moufStr); // Change rights on Mouf.php, but ignore errors (the file might be writable but still belong to someone else). @chmod(__DIR__."/../../../../../../mouf/Mouf.php", 0664); //} // Write MoufComponents.php: if (!file_exists(__DIR__."/../../../../../../mouf/MoufComponents.php")) { $moufComponentsStr = "<?php /** * This is a file automatically generated by the Mouf framework. Do not modify it, as it could be overwritten. */ use Mouf\MoufManager; MoufManager::initMoufManager(); \$moufManager = MoufManager::getMoufManager(); ?>"; file_put_contents(__DIR__."/../../../../../../mouf/MoufComponents.php", $moufComponentsStr); chmod(__DIR__."/../../../../../../mouf/MoufComponents.php", 0664); } // Finally, let's generate the MoufUI.php file: if (!file_exists(__DIR__."/../../../../../../mouf/MoufUI.php")) { $moufUIStr = "<?php /** * This is a file automatically generated by the Mouf framework. Do not modify it, as it could be overwritten. */ ?>"; file_put_contents(__DIR__."/../../../../../../mouf/MoufUI.php", $moufUIStr); chmod(__DIR__."/../../../../../../mouf/MoufUI.php", 0664); } // Finally 2, let's generate the config.php file: if (!file_exists(__DIR__."/../../../../../../config.php")) { $moufConfig = "<?php /** * This is a file automatically generated by the Mouf framework. Do not modify it, as it could be overwritten. * Use the UI to edit it instead. */ ?>"; file_put_contents(__DIR__."/../../../../../../config.php", $moufConfig); chmod(__DIR__."/../../../../../../config.php", 0664); } // Finally 3 :), let's generate the MoufUsers.php file: if (!file_exists(__DIR__."/../../../../../../mouf/no_commit/MoufUsers.php")) { $moufConfig = "<?php /** * This contains the users allowed to access the Mouf framework. */ \$users[".var_export(userinput_to_plainstring($_REQUEST['login']), true)."] = array('password'=>".var_export(sha1(userinput_to_plainstring($_REQUEST['password'])), true).", 'options'=>null); ?>"; file_put_contents(__DIR__."/../../../../../../mouf/no_commit/MoufUsers.php", $moufConfig); chmod(__DIR__."/../../../../../../mouf/no_commit/MoufUsers.php", 0664); } umask($oldUmask); header("Location: ".ROOT_URL); }
php
public function install() { if (file_exists(__DIR__.'/../../../../../../mouf/no_commit/MoufUsers.php')) { $this->contentBlock->addFile(dirname(__FILE__)."/../../views/mouf_installer/moufusers_exists.php", $this); $this->template->toHtml(); return; } $oldUmask = umask(); umask(0); // Now, let's write the basic Mouf files: if (!file_exists(__DIR__."/../../../../../../mouf")) { mkdir(__DIR__."/../../../../../../mouf", 0775); } if (!file_exists(__DIR__."/../../../../../../mouf/no_commit")) { mkdir(__DIR__."/../../../../../../mouf/no_commit", 0775); } // Write Mouf.php (always): //if (!file_exists(__DIR__."/../../../../../../mouf/Mouf.php")) { $moufStr = "<?php define('ROOT_PATH', realpath(__DIR__.'/..').DIRECTORY_SEPARATOR); require_once __DIR__.'/../config.php'; if (defined('ROOT_URL')) { define('MOUF_URL', ROOT_URL.'vendor/mouf/mouf/'); } require_once __DIR__.'/../vendor/autoload.php'; require_once 'MoufComponents.php'; ?>"; file_put_contents(__DIR__."/../../../../../../mouf/Mouf.php", $moufStr); // Change rights on Mouf.php, but ignore errors (the file might be writable but still belong to someone else). @chmod(__DIR__."/../../../../../../mouf/Mouf.php", 0664); //} // Write MoufComponents.php: if (!file_exists(__DIR__."/../../../../../../mouf/MoufComponents.php")) { $moufComponentsStr = "<?php /** * This is a file automatically generated by the Mouf framework. Do not modify it, as it could be overwritten. */ use Mouf\MoufManager; MoufManager::initMoufManager(); \$moufManager = MoufManager::getMoufManager(); ?>"; file_put_contents(__DIR__."/../../../../../../mouf/MoufComponents.php", $moufComponentsStr); chmod(__DIR__."/../../../../../../mouf/MoufComponents.php", 0664); } // Finally, let's generate the MoufUI.php file: if (!file_exists(__DIR__."/../../../../../../mouf/MoufUI.php")) { $moufUIStr = "<?php /** * This is a file automatically generated by the Mouf framework. Do not modify it, as it could be overwritten. */ ?>"; file_put_contents(__DIR__."/../../../../../../mouf/MoufUI.php", $moufUIStr); chmod(__DIR__."/../../../../../../mouf/MoufUI.php", 0664); } // Finally 2, let's generate the config.php file: if (!file_exists(__DIR__."/../../../../../../config.php")) { $moufConfig = "<?php /** * This is a file automatically generated by the Mouf framework. Do not modify it, as it could be overwritten. * Use the UI to edit it instead. */ ?>"; file_put_contents(__DIR__."/../../../../../../config.php", $moufConfig); chmod(__DIR__."/../../../../../../config.php", 0664); } // Finally 3 :), let's generate the MoufUsers.php file: if (!file_exists(__DIR__."/../../../../../../mouf/no_commit/MoufUsers.php")) { $moufConfig = "<?php /** * This contains the users allowed to access the Mouf framework. */ \$users[".var_export(userinput_to_plainstring($_REQUEST['login']), true)."] = array('password'=>".var_export(sha1(userinput_to_plainstring($_REQUEST['password'])), true).", 'options'=>null); ?>"; file_put_contents(__DIR__."/../../../../../../mouf/no_commit/MoufUsers.php", $moufConfig); chmod(__DIR__."/../../../../../../mouf/no_commit/MoufUsers.php", 0664); } umask($oldUmask); header("Location: ".ROOT_URL); }
[ "public", "function", "install", "(", ")", "{", "if", "(", "file_exists", "(", "__DIR__", ".", "'/../../../../../../mouf/no_commit/MoufUsers.php'", ")", ")", "{", "$", "this", "->", "contentBlock", "->", "addFile", "(", "dirname", "(", "__FILE__", ")", ".", "\...
Performs the installation by creating all required files. @URL install
[ "Performs", "the", "installation", "by", "creating", "all", "required", "files", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/MoufInstallController.php#L87-L190
train
thecodingmachine/mouf
src/Mouf/Reflection/MoufXmlReflectionMethod.php
MoufXmlReflectionMethod.getParameter
public function getParameter($name) { foreach ($this->xmlRoot->parameter as $parameter) { if ($method['name'] == $name) { $moufRefParameter = new MoufXmlReflectionParameter($this, $parameter); return $moufRefParameter; } } return null; }
php
public function getParameter($name) { foreach ($this->xmlRoot->parameter as $parameter) { if ($method['name'] == $name) { $moufRefParameter = new MoufXmlReflectionParameter($this, $parameter); return $moufRefParameter; } } return null; }
[ "public", "function", "getParameter", "(", "$", "name", ")", "{", "foreach", "(", "$", "this", "->", "xmlRoot", "->", "parameter", "as", "$", "parameter", ")", "{", "if", "(", "$", "method", "[", "'name'", "]", "==", "$", "name", ")", "{", "$", "mo...
returns the specified parameter or null if it does not exist @param string $name name of parameter to return @return MoufXmlParameterMethod
[ "returns", "the", "specified", "parameter", "or", "null", "if", "it", "does", "not", "exist" ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/MoufXmlReflectionMethod.php#L219-L228
train
thecodingmachine/mouf
src-dev/Mouf/Controllers/MoufController.php
MoufController.getAnonymousInstanceName
private function getAnonymousInstanceName($instanceName) { // Let's find a name for this anonymous instance $anonInstanceName = $instanceName; // Let's find where the anonymous instance is used. do { $parents = $this->moufManager->getOwnerComponents($anonInstanceName); // There should be only one parent, since this is an anonymous instance $anonInstanceName = current($parents); } while ($this->moufManager->getInstanceDescriptor($anonInstanceName)->isAnonymous()); return "Anonymous (parent: ".$anonInstanceName.")"; }
php
private function getAnonymousInstanceName($instanceName) { // Let's find a name for this anonymous instance $anonInstanceName = $instanceName; // Let's find where the anonymous instance is used. do { $parents = $this->moufManager->getOwnerComponents($anonInstanceName); // There should be only one parent, since this is an anonymous instance $anonInstanceName = current($parents); } while ($this->moufManager->getInstanceDescriptor($anonInstanceName)->isAnonymous()); return "Anonymous (parent: ".$anonInstanceName.")"; }
[ "private", "function", "getAnonymousInstanceName", "(", "$", "instanceName", ")", "{", "// Let's find a name for this anonymous instance", "$", "anonInstanceName", "=", "$", "instanceName", ";", "// Let's find where the anonymous instance is used.", "do", "{", "$", "parents", ...
Returns a printable name for this anonymous instance. @param string $instanceName @return string
[ "Returns", "a", "printable", "name", "for", "this", "anonymous", "instance", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/MoufController.php#L370-L381
train
thecodingmachine/mouf
src-dev/Mouf/Controllers/MoufController.php
MoufController.instancesByDate
public function instancesByDate($selfedit = "false") { $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } $this->contentBlock->addFile(dirname(__FILE__)."/../views/listComponents.php", $this); $this->template->toHtml(); }
php
public function instancesByDate($selfedit = "false") { $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } $this->contentBlock->addFile(dirname(__FILE__)."/../views/listComponents.php", $this); $this->template->toHtml(); }
[ "public", "function", "instancesByDate", "(", "$", "selfedit", "=", "\"false\"", ")", "{", "$", "this", "->", "selfedit", "=", "$", "selfedit", ";", "if", "(", "$", "selfedit", "==", "\"true\"", ")", "{", "$", "this", "->", "moufManager", "=", "MoufManag...
Lists all the components available, ordered by creation date, in order to edit them. @Action @Logged
[ "Lists", "all", "the", "components", "available", "ordered", "by", "creation", "date", "in", "order", "to", "edit", "them", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/MoufController.php#L389-L400
train
thecodingmachine/mouf
src-dev/Mouf/Controllers/MoufController.php
MoufController.refreshNewInstance
public function refreshNewInstance($selfedit = "false", $instanceName=null, $instanceClass=null) { $moufCache = new MoufCache(); $moufCache->purgeAll(); header("Location: newInstance2?selfedit=".$selfedit."&instanceName=".urlencode($instanceName)."&instanceClass=".urlencode($instanceClass)); }
php
public function refreshNewInstance($selfedit = "false", $instanceName=null, $instanceClass=null) { $moufCache = new MoufCache(); $moufCache->purgeAll(); header("Location: newInstance2?selfedit=".$selfedit."&instanceName=".urlencode($instanceName)."&instanceClass=".urlencode($instanceClass)); }
[ "public", "function", "refreshNewInstance", "(", "$", "selfedit", "=", "\"false\"", ",", "$", "instanceName", "=", "null", ",", "$", "instanceClass", "=", "null", ")", "{", "$", "moufCache", "=", "new", "MoufCache", "(", ")", ";", "$", "moufCache", "->", ...
Purge the cache and redisplays the screen allowing to create new instances. @Action @Logged
[ "Purge", "the", "cache", "and", "redisplays", "the", "screen", "allowing", "to", "create", "new", "instances", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/MoufController.php#L441-L446
train
thecodingmachine/mouf
src-dev/Mouf/Controllers/MoufController.php
MoufController.createComponent
public function createComponent($instanceName, $instanceClass, $selfedit) { $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } $this->moufManager->declareComponent($instanceName, $instanceClass); $this->moufManager->rewriteMouf(); // Redirect to the display component page: $this->displayComponent($instanceName, $selfedit); }
php
public function createComponent($instanceName, $instanceClass, $selfedit) { $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } $this->moufManager->declareComponent($instanceName, $instanceClass); $this->moufManager->rewriteMouf(); // Redirect to the display component page: $this->displayComponent($instanceName, $selfedit); }
[ "public", "function", "createComponent", "(", "$", "instanceName", ",", "$", "instanceClass", ",", "$", "selfedit", ")", "{", "$", "this", "->", "selfedit", "=", "$", "selfedit", ";", "if", "(", "$", "selfedit", "==", "\"true\"", ")", "{", "$", "this", ...
The action that creates a new component instance. @Action @Logged @param string $instanceName The name of the instance to create @param string $instanceClass The class of the component to create
[ "The", "action", "that", "creates", "a", "new", "component", "instance", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/MoufController.php#L464-L479
train
thecodingmachine/mouf
src-dev/Mouf/Controllers/MoufController.php
MoufController.deleteInstance
public function deleteInstance($selfedit = "false", $instanceName=null, $returnurl = null) { $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } $this->moufManager->removeComponent($instanceName); $this->moufManager->rewriteMouf(); if ($returnurl) { header("Location:".$returnurl); } else { header("Location: .?selfedit=".$selfedit); } }
php
public function deleteInstance($selfedit = "false", $instanceName=null, $returnurl = null) { $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } $this->moufManager->removeComponent($instanceName); $this->moufManager->rewriteMouf(); if ($returnurl) { header("Location:".$returnurl); } else { header("Location: .?selfedit=".$selfedit); } }
[ "public", "function", "deleteInstance", "(", "$", "selfedit", "=", "\"false\"", ",", "$", "instanceName", "=", "null", ",", "$", "returnurl", "=", "null", ")", "{", "$", "this", "->", "selfedit", "=", "$", "selfedit", ";", "if", "(", "$", "selfedit", "...
Removes the instance passed in parameter. @Action @Logged
[ "Removes", "the", "instance", "passed", "in", "parameter", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/MoufController.php#L487-L504
train
thecodingmachine/mouf
src-dev/Mouf/Controllers/MoufController.php
MoufController.deleteInstances
public function deleteInstances($selfedit = "false", $instancesNames = array(), $returnurl = null) { $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } if(!empty($instancesNames)) { foreach($instancesNames as $instanceName) { $this->moufManager->removeComponent($instanceName); } $this->moufManager->rewriteMouf(); } if ($returnurl) { header("Location:".$returnurl); } else { header("Location: .?selfedit=".$selfedit); } }
php
public function deleteInstances($selfedit = "false", $instancesNames = array(), $returnurl = null) { $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } if(!empty($instancesNames)) { foreach($instancesNames as $instanceName) { $this->moufManager->removeComponent($instanceName); } $this->moufManager->rewriteMouf(); } if ($returnurl) { header("Location:".$returnurl); } else { header("Location: .?selfedit=".$selfedit); } }
[ "public", "function", "deleteInstances", "(", "$", "selfedit", "=", "\"false\"", ",", "$", "instancesNames", "=", "array", "(", ")", ",", "$", "returnurl", "=", "null", ")", "{", "$", "this", "->", "selfedit", "=", "$", "selfedit", ";", "if", "(", "$",...
Removes all the instances passed in parameter @Action @Logged @param string $selfedit @param array $instancesNames @param string $returnurl @throws \Mouf\MoufException
[ "Removes", "all", "the", "instances", "passed", "in", "parameter" ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/MoufController.php#L515-L536
train
thecodingmachine/mouf
src-dev/Mouf/Controllers/MoufController.php
MoufController.newInstanceByCallback
public function newInstanceByCallback($selfedit = "false", $instanceName=null) { $this->instanceName = $instanceName; $this->selfedit = $selfedit; $this->contentBlock->addFile(dirname(__FILE__)."/../../views/instances/newInstanceByCallback.php", $this); $this->template->toHtml(); }
php
public function newInstanceByCallback($selfedit = "false", $instanceName=null) { $this->instanceName = $instanceName; $this->selfedit = $selfedit; $this->contentBlock->addFile(dirname(__FILE__)."/../../views/instances/newInstanceByCallback.php", $this); $this->template->toHtml(); }
[ "public", "function", "newInstanceByCallback", "(", "$", "selfedit", "=", "\"false\"", ",", "$", "instanceName", "=", "null", ")", "{", "$", "this", "->", "instanceName", "=", "$", "instanceName", ";", "$", "this", "->", "selfedit", "=", "$", "selfedit", "...
Displays the screen allowing to create a new instance by PHP code. @Action @Logged
[ "Displays", "the", "screen", "allowing", "to", "create", "a", "new", "instance", "by", "PHP", "code", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/MoufController.php#L567-L573
train
thecodingmachine/mouf
src-dev/Mouf/Controllers/MoufController.php
MoufController.createInstanceByCode
public function createInstanceByCode($selfedit = "false", $instanceName=null) { if (!$instanceName) { $this->newInstanceByCallback(); return; } $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } $this->moufManager->createInstanceByCode()->setName($instanceName); $this->moufManager->rewriteMouf(); header("Location: ".MOUF_URL."ajaxinstance/?name=".urlencode($instanceName)."&selfedit=".$selfedit); }
php
public function createInstanceByCode($selfedit = "false", $instanceName=null) { if (!$instanceName) { $this->newInstanceByCallback(); return; } $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } $this->moufManager->createInstanceByCode()->setName($instanceName); $this->moufManager->rewriteMouf(); header("Location: ".MOUF_URL."ajaxinstance/?name=".urlencode($instanceName)."&selfedit=".$selfedit); }
[ "public", "function", "createInstanceByCode", "(", "$", "selfedit", "=", "\"false\"", ",", "$", "instanceName", "=", "null", ")", "{", "if", "(", "!", "$", "instanceName", ")", "{", "$", "this", "->", "newInstanceByCallback", "(", ")", ";", "return", ";", ...
Performs the action of creating a new instance. @Action @Logged
[ "Performs", "the", "action", "of", "creating", "a", "new", "instance", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/MoufController.php#L581-L598
train
thecodingmachine/mouf
src-dev/Mouf/Controllers/InstallController.php
InstallController.index
public function index($selfedit = false) { $this->selfedit = $selfedit; $this->installService = new ComposerInstaller($selfedit == 'true'); $this->installs = $this->installService->getInstallTasks(); //var_dump($this->installs);exit; $this->countNbTodo = 0; foreach ($this->installs as $installTask) { if ($installTask->getStatus() == AbstractInstallTask::STATUS_TODO) { $this->countNbTodo++; } } $this->contentBlock->addFile(dirname(__FILE__)."/../../views/installer/installTasksList.php", $this); $this->template->toHtml(); }
php
public function index($selfedit = false) { $this->selfedit = $selfedit; $this->installService = new ComposerInstaller($selfedit == 'true'); $this->installs = $this->installService->getInstallTasks(); //var_dump($this->installs);exit; $this->countNbTodo = 0; foreach ($this->installs as $installTask) { if ($installTask->getStatus() == AbstractInstallTask::STATUS_TODO) { $this->countNbTodo++; } } $this->contentBlock->addFile(dirname(__FILE__)."/../../views/installer/installTasksList.php", $this); $this->template->toHtml(); }
[ "public", "function", "index", "(", "$", "selfedit", "=", "false", ")", "{", "$", "this", "->", "selfedit", "=", "$", "selfedit", ";", "$", "this", "->", "installService", "=", "new", "ComposerInstaller", "(", "$", "selfedit", "==", "'true'", ")", ";", ...
Displays the page to install packages @Action @Logged @param string $selfedit If true, we are in self-edit mode
[ "Displays", "the", "page", "to", "install", "packages" ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/InstallController.php#L72-L86
train
thecodingmachine/mouf
src-dev/Mouf/Controllers/InstallController.php
InstallController.install
public function install($selfedit = 'false', $task = null) { $this->selfedit = $selfedit; $this->installService = new ComposerInstaller($selfedit == 'true'); if ($task !== null) { $taskArray = unserialize($task); } else { $taskArray = null; } if ($taskArray == null) { $this->installService->installAll(); } else { $this->installService->install($taskArray); } // The call to install or installAll redirects to printInstallationScreen. }
php
public function install($selfedit = 'false', $task = null) { $this->selfedit = $selfedit; $this->installService = new ComposerInstaller($selfedit == 'true'); if ($task !== null) { $taskArray = unserialize($task); } else { $taskArray = null; } if ($taskArray == null) { $this->installService->installAll(); } else { $this->installService->install($taskArray); } // The call to install or installAll redirects to printInstallationScreen. }
[ "public", "function", "install", "(", "$", "selfedit", "=", "'false'", ",", "$", "task", "=", "null", ")", "{", "$", "this", "->", "selfedit", "=", "$", "selfedit", ";", "$", "this", "->", "installService", "=", "new", "ComposerInstaller", "(", "$", "s...
This page starts the install proces of one task or all tasks in "todo" state. @Action @Logged @param string $selfedit If true, we are in self-edit mode
[ "This", "page", "starts", "the", "install", "proces", "of", "one", "task", "or", "all", "tasks", "in", "todo", "state", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/InstallController.php#L98-L114
train
thecodingmachine/mouf
src-dev/Mouf/Controllers/InstallController.php
InstallController.printInstallationScreen
public function printInstallationScreen($selfedit = 'false') { $this->selfedit = $selfedit; $this->installService = new ComposerInstaller($selfedit == 'true'); $this->installs = $this->installService->getInstallTasks(); $this->contentBlock->addFile(dirname(__FILE__)."/../../views/installer/processing.php", $this); $this->template->toHtml(); }
php
public function printInstallationScreen($selfedit = 'false') { $this->selfedit = $selfedit; $this->installService = new ComposerInstaller($selfedit == 'true'); $this->installs = $this->installService->getInstallTasks(); $this->contentBlock->addFile(dirname(__FILE__)."/../../views/installer/processing.php", $this); $this->template->toHtml(); }
[ "public", "function", "printInstallationScreen", "(", "$", "selfedit", "=", "'false'", ")", "{", "$", "this", "->", "selfedit", "=", "$", "selfedit", ";", "$", "this", "->", "installService", "=", "new", "ComposerInstaller", "(", "$", "selfedit", "==", "'tru...
Installation screen is displayed and the user is directly redirected via Javascript to the install page. @Action @param string $selfedit
[ "Installation", "screen", "is", "displayed", "and", "the", "user", "is", "directly", "redirected", "via", "Javascript", "to", "the", "install", "page", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/InstallController.php#L122-L129
train
thecodingmachine/mouf
src-dev/Mouf/Controllers/InstallController.php
InstallController.processInstall
public function processInstall($selfedit = 'false') { // Let's process install now by redirecting HERE! $this->selfedit = $selfedit; $this->installService = new ComposerInstaller($selfedit == 'true'); $installTask = $this->installService->getNextInstallTask(); header("Location: ".MOUF_URL.$installTask->getRedirectUrl($selfedit == 'true')); }
php
public function processInstall($selfedit = 'false') { // Let's process install now by redirecting HERE! $this->selfedit = $selfedit; $this->installService = new ComposerInstaller($selfedit == 'true'); $installTask = $this->installService->getNextInstallTask(); header("Location: ".MOUF_URL.$installTask->getRedirectUrl($selfedit == 'true')); }
[ "public", "function", "processInstall", "(", "$", "selfedit", "=", "'false'", ")", "{", "// Let's process install now by redirecting HERE!", "$", "this", "->", "selfedit", "=", "$", "selfedit", ";", "$", "this", "->", "installService", "=", "new", "ComposerInstaller...
Starts the installation process for one package registered with install or installAll. @Action @param string $selfedit
[ "Starts", "the", "installation", "process", "for", "one", "package", "registered", "with", "install", "or", "installAll", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/InstallController.php#L137-L144
train
thecodingmachine/mouf
src-dev/Mouf/Controllers/InstallController.php
InstallController.installTaskDone
public function installTaskDone($selfedit = 'false') { $this->selfedit = $selfedit; $this->installService = new ComposerInstaller($selfedit == 'true'); $this->installService->validateCurrentInstall(); $installTask = $this->installService->getNextInstallTask(); if ($installTask) { $this->printInstallationScreen($selfedit); } else { set_user_message("Installation process succeeded!", UserMessageInterface::SUCCESS); header("Location: .?selfedit=".$selfedit); } }
php
public function installTaskDone($selfedit = 'false') { $this->selfedit = $selfedit; $this->installService = new ComposerInstaller($selfedit == 'true'); $this->installService->validateCurrentInstall(); $installTask = $this->installService->getNextInstallTask(); if ($installTask) { $this->printInstallationScreen($selfedit); } else { set_user_message("Installation process succeeded!", UserMessageInterface::SUCCESS); header("Location: .?selfedit=".$selfedit); } }
[ "public", "function", "installTaskDone", "(", "$", "selfedit", "=", "'false'", ")", "{", "$", "this", "->", "selfedit", "=", "$", "selfedit", ";", "$", "this", "->", "installService", "=", "new", "ComposerInstaller", "(", "$", "selfedit", "==", "'true'", "...
Action called when a full install step has completed. @Action @param string $selfedit
[ "Action", "called", "when", "a", "full", "install", "step", "has", "completed", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/InstallController.php#L152-L166
train
thecodingmachine/mouf
src/Mouf/Composer/ChunckedUtils.php
ChunckedUtils.init
public static function init() { header("Transfer-Encoding: chunked"); @apache_setenv('no-gzip', 1); @ini_set('zlib.output_compression', 0); @ini_set('implicit_flush', 1); for ($i = 0; $i < ob_get_level(); $i++) ob_end_flush(); ob_implicit_flush(1); flush(); $pad = str_pad('',4096); echo dechex(strlen($pad))."\r\n"; echo $pad; echo "\r\n"; }
php
public static function init() { header("Transfer-Encoding: chunked"); @apache_setenv('no-gzip', 1); @ini_set('zlib.output_compression', 0); @ini_set('implicit_flush', 1); for ($i = 0; $i < ob_get_level(); $i++) ob_end_flush(); ob_implicit_flush(1); flush(); $pad = str_pad('',4096); echo dechex(strlen($pad))."\r\n"; echo $pad; echo "\r\n"; }
[ "public", "static", "function", "init", "(", ")", "{", "header", "(", "\"Transfer-Encoding: chunked\"", ")", ";", "@", "apache_setenv", "(", "'no-gzip'", ",", "1", ")", ";", "@", "ini_set", "(", "'zlib.output_compression'", ",", "0", ")", ";", "@", "ini_set"...
Sends the "chuncked" header to the browser announcing we will be sending chuncks.
[ "Sends", "the", "chuncked", "header", "to", "the", "browser", "announcing", "we", "will", "be", "sending", "chuncks", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Composer/ChunckedUtils.php#L15-L27
train
thecodingmachine/mouf
src/Mouf/Reflection/MoufXmlReflectionClass.php
MoufXmlReflectionClass.getMethodsByPattern
public function getMethodsByPattern($regex) { $methods = array(); foreach ($this->xmlRoot->method as $method) { if (preg_match("/$regex/", $method['name'])) { $moufRefMethod = new MoufXmlReflectionMethod($this, $method); $methods[] = $moufRefMethod; } } return $methods; }
php
public function getMethodsByPattern($regex) { $methods = array(); foreach ($this->xmlRoot->method as $method) { if (preg_match("/$regex/", $method['name'])) { $moufRefMethod = new MoufXmlReflectionMethod($this, $method); $methods[] = $moufRefMethod; } } return $methods; }
[ "public", "function", "getMethodsByPattern", "(", "$", "regex", ")", "{", "$", "methods", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "xmlRoot", "->", "method", "as", "$", "method", ")", "{", "if", "(", "preg_match", "(", "\"/$regex...
returns methods mathcing the given pattern @param string $regex the regular expression to match (without trailing slashes) @return array<MoufXmlReflectionMethod>
[ "returns", "methods", "mathcing", "the", "given", "pattern" ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/MoufXmlReflectionClass.php#L203-L213
train
thecodingmachine/mouf
src/Mouf/Reflection/MoufReflectionParameter.php
MoufReflectionParameter.getDeclaringClass
public function getDeclaringClass() { if (is_array($this->routineName) === false) { return null; } $refClass = parent::getDeclaringClass(); $moufRefClass = new MoufReflectionClass($refClass->getName()); return $moufRefClass; }
php
public function getDeclaringClass() { if (is_array($this->routineName) === false) { return null; } $refClass = parent::getDeclaringClass(); $moufRefClass = new MoufReflectionClass($refClass->getName()); return $moufRefClass; }
[ "public", "function", "getDeclaringClass", "(", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "routineName", ")", "===", "false", ")", "{", "return", "null", ";", "}", "$", "refClass", "=", "parent", "::", "getDeclaringClass", "(", ")", ";", ...
returns the class that declares this parameter @return stubReflectionClass
[ "returns", "the", "class", "that", "declares", "this", "parameter" ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/MoufReflectionParameter.php#L113-L122
train
thecodingmachine/mouf
src/Mouf/Reflection/MoufReflectionParameter.php
MoufReflectionParameter.getClassName
function getClassName() { preg_match('/\[\s\<\w+?>\s([\w\\\\]+)/s', $this->__toString(), $matches); $class = isset($matches[1]) ? $matches[1] : null; if(in_array($class, [ 'array', 'string', 'char', 'bool', 'boolean', 'int', 'integer', 'double', 'float', 'real', 'mixed', 'number', 'null', 'callable', 'callback' ])) { return null; } return $class; }
php
function getClassName() { preg_match('/\[\s\<\w+?>\s([\w\\\\]+)/s', $this->__toString(), $matches); $class = isset($matches[1]) ? $matches[1] : null; if(in_array($class, [ 'array', 'string', 'char', 'bool', 'boolean', 'int', 'integer', 'double', 'float', 'real', 'mixed', 'number', 'null', 'callable', 'callback' ])) { return null; } return $class; }
[ "function", "getClassName", "(", ")", "{", "preg_match", "(", "'/\\[\\s\\<\\w+?>\\s([\\w\\\\\\\\]+)/s'", ",", "$", "this", "->", "__toString", "(", ")", ",", "$", "matches", ")", ";", "$", "class", "=", "isset", "(", "$", "matches", "[", "1", "]", ")", "...
Retrieve only the class name without requiring the class to exist @return string|null
[ "Retrieve", "only", "the", "class", "name", "without", "requiring", "the", "class", "to", "exist" ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/MoufReflectionParameter.php#L154-L161
train
thecodingmachine/mouf
src/Mouf/Reflection/MoufReflectionParameter.php
MoufReflectionParameter.toJson
public function toJson() { $result = array(); $result['name'] = $this->getName(); $result['hasDefault'] = $this->isDefaultValueAvailable(); try { if ($result['hasDefault']) { // In some cases, the call to getDefaultValue can log NOTICES // in particular if an undefined constant is used as default value. ob_start(); if ($this->isDefaultValueConstant() && !defined($this->getDefaultValueConstantName())) { throw new \Exception('Constant "'.$this->getDefaultValueConstantName().'" does not exist.'); } $result['default'] = $this->getDefaultValue(); $possibleError = ob_get_clean(); if ($possibleError) { throw new \Exception($possibleError); } } $result['isArray'] = $this->isArray(); // Let's export only the type if we are in a constructor... in order to save time. if ($this->getDeclaringFunction()->isConstructor()) { // TODO: is there a need to instanciate a MoufPropertyDescriptor? $moufPropertyDescriptor = new MoufPropertyDescriptor($this); $result['comment'] = $moufPropertyDescriptor->getDocCommentWithoutAnnotations(); $types = $moufPropertyDescriptor->getTypes(); $result['types'] = $types->toJson(); if ($types->getWarningMessage()) { $result['classinerror'] = $types->getWarningMessage(); } /*if ($moufPropertyDescriptor->isAssociativeArray()) { $result['keytype'] = $moufPropertyDescriptor->getKeyType(); } if ($moufPropertyDescriptor->isArray()) { $result['subtype'] = $moufPropertyDescriptor->getSubType(); }*/ } } catch (\Exception $e) { $result['classinerror'] = $e->getMessage(); } return $result; }
php
public function toJson() { $result = array(); $result['name'] = $this->getName(); $result['hasDefault'] = $this->isDefaultValueAvailable(); try { if ($result['hasDefault']) { // In some cases, the call to getDefaultValue can log NOTICES // in particular if an undefined constant is used as default value. ob_start(); if ($this->isDefaultValueConstant() && !defined($this->getDefaultValueConstantName())) { throw new \Exception('Constant "'.$this->getDefaultValueConstantName().'" does not exist.'); } $result['default'] = $this->getDefaultValue(); $possibleError = ob_get_clean(); if ($possibleError) { throw new \Exception($possibleError); } } $result['isArray'] = $this->isArray(); // Let's export only the type if we are in a constructor... in order to save time. if ($this->getDeclaringFunction()->isConstructor()) { // TODO: is there a need to instanciate a MoufPropertyDescriptor? $moufPropertyDescriptor = new MoufPropertyDescriptor($this); $result['comment'] = $moufPropertyDescriptor->getDocCommentWithoutAnnotations(); $types = $moufPropertyDescriptor->getTypes(); $result['types'] = $types->toJson(); if ($types->getWarningMessage()) { $result['classinerror'] = $types->getWarningMessage(); } /*if ($moufPropertyDescriptor->isAssociativeArray()) { $result['keytype'] = $moufPropertyDescriptor->getKeyType(); } if ($moufPropertyDescriptor->isArray()) { $result['subtype'] = $moufPropertyDescriptor->getSubType(); }*/ } } catch (\Exception $e) { $result['classinerror'] = $e->getMessage(); } return $result; }
[ "public", "function", "toJson", "(", ")", "{", "$", "result", "=", "array", "(", ")", ";", "$", "result", "[", "'name'", "]", "=", "$", "this", "->", "getName", "(", ")", ";", "$", "result", "[", "'hasDefault'", "]", "=", "$", "this", "->", "isDe...
Returns a PHP array representing the parameter. @return array
[ "Returns", "a", "PHP", "array", "representing", "the", "parameter", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/MoufReflectionParameter.php#L201-L247
train
thecodingmachine/mouf
src/Mouf/Reflection/TypesDescriptor.php
TypesDescriptor.runLexer
public static function runLexer($line) { $tokens = array(); $offset = 0; while($offset < strlen($line)) { $result = static::_match($line, $offset); if($result === false) { throw new MoufException("Unable to parse line '".$line."'."); } $tokens[] = $result; $offset += strlen($result['match']); } return $tokens; }
php
public static function runLexer($line) { $tokens = array(); $offset = 0; while($offset < strlen($line)) { $result = static::_match($line, $offset); if($result === false) { throw new MoufException("Unable to parse line '".$line."'."); } $tokens[] = $result; $offset += strlen($result['match']); } return $tokens; }
[ "public", "static", "function", "runLexer", "(", "$", "line", ")", "{", "$", "tokens", "=", "array", "(", ")", ";", "$", "offset", "=", "0", ";", "while", "(", "$", "offset", "<", "strlen", "(", "$", "line", ")", ")", "{", "$", "result", "=", "...
Runs the analysis @param $line @throws MoufException @return array
[ "Runs", "the", "analysis" ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/TypesDescriptor.php#L136-L149
train
thecodingmachine/mouf
src/Mouf/Reflection/TypesDescriptor.php
TypesDescriptor.toJson
public function toJson() { $array = array("types"=>array()); foreach ($this->types as $type) { $array["types"][] = $type->toJson(); } if ($this->warningMessage) { $array["warning"] = $this->warningMessage; } return $array; }
php
public function toJson() { $array = array("types"=>array()); foreach ($this->types as $type) { $array["types"][] = $type->toJson(); } if ($this->warningMessage) { $array["warning"] = $this->warningMessage; } return $array; }
[ "public", "function", "toJson", "(", ")", "{", "$", "array", "=", "array", "(", "\"types\"", "=>", "array", "(", ")", ")", ";", "foreach", "(", "$", "this", "->", "types", "as", "$", "type", ")", "{", "$", "array", "[", "\"types\"", "]", "[", "]"...
Returns a PHP array representing the TypesDescriptor @return array
[ "Returns", "a", "PHP", "array", "representing", "the", "TypesDescriptor" ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/TypesDescriptor.php#L156-L165
train
thecodingmachine/mouf
src/Mouf/Reflection/TypesDescriptor.php
TypesDescriptor.getCompatibleTypeForInstance
public function getCompatibleTypeForInstance($value) { foreach ($this->types as $type) { if ($type->isCompatible($value)) { return $type; } } return null; }
php
public function getCompatibleTypeForInstance($value) { foreach ($this->types as $type) { if ($type->isCompatible($value)) { return $type; } } return null; }
[ "public", "function", "getCompatibleTypeForInstance", "(", "$", "value", ")", "{", "foreach", "(", "$", "this", "->", "types", "as", "$", "type", ")", "{", "if", "(", "$", "type", "->", "isCompatible", "(", "$", "value", ")", ")", "{", "return", "$", ...
Returns the TypeDescriptor that is part of these types that is the most likely to fit the propertyDescriptor's value passed in parameter. Returns null if no type is compatible. @param string|array|MoufInstanceDescriptor|MoufInstanceDescriptor[] $instanceDescriptor @return TypeDescriptor
[ "Returns", "the", "TypeDescriptor", "that", "is", "part", "of", "these", "types", "that", "is", "the", "most", "likely", "to", "fit", "the", "propertyDescriptor", "s", "value", "passed", "in", "parameter", ".", "Returns", "null", "if", "no", "type", "is", ...
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/TypesDescriptor.php#L196-L203
train
thecodingmachine/mouf
src-dev/Mouf/Validator/MoufBasicValidationProvider.php
MoufBasicValidationProvider.getUrl
public function getUrl() { $url = $this->url; $params = array(); // First, get the list of all parameters to be propagated if (is_array($this->propagatedUrlParameters)) { foreach ($this->propagatedUrlParameters as $parameter) { if (isset($_REQUEST[$parameter])) { $params[$parameter] = get($parameter); } } } if (!empty($params)) { if (strpos($url, "?") === FALSE) { $url .= "?"; } else { $url .= "&"; } $paramsAsStrArray = array(); foreach ($params as $key=>$value) { $paramsAsStrArray[] = urlencode($key).'='.urlencode($value); } $url .= implode("&", $paramsAsStrArray); } return $url; }
php
public function getUrl() { $url = $this->url; $params = array(); // First, get the list of all parameters to be propagated if (is_array($this->propagatedUrlParameters)) { foreach ($this->propagatedUrlParameters as $parameter) { if (isset($_REQUEST[$parameter])) { $params[$parameter] = get($parameter); } } } if (!empty($params)) { if (strpos($url, "?") === FALSE) { $url .= "?"; } else { $url .= "&"; } $paramsAsStrArray = array(); foreach ($params as $key=>$value) { $paramsAsStrArray[] = urlencode($key).'='.urlencode($value); } $url .= implode("&", $paramsAsStrArray); } return $url; }
[ "public", "function", "getUrl", "(", ")", "{", "$", "url", "=", "$", "this", "->", "url", ";", "$", "params", "=", "array", "(", ")", ";", "// First, get the list of all parameters to be propagated\r", "if", "(", "is_array", "(", "$", "this", "->", "propagat...
Returns the URL that will be called for that validator. The URL is relative to the ROOT_URL. The URL will return HTML code that will directly be displayed in the Mouf validation screen. @return string
[ "Returns", "the", "URL", "that", "will", "be", "called", "for", "that", "validator", ".", "The", "URL", "is", "relative", "to", "the", "ROOT_URL", ".", "The", "URL", "will", "return", "HTML", "code", "that", "will", "directly", "be", "displayed", "in", "...
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Validator/MoufBasicValidationProvider.php#L72-L99
train
Lecturize/Laravel-Taxonomies
src/Models/Term.php
Term.getDisplayName
public function getDisplayName($locale = '', $limit = 0) { $locale = $locale ?: app()->getLocale(); $property_with_locale = $locale === 'en' ? "name" : "name_$locale"; $name = property_exists($this, $property_with_locale) ? $this->{$property_with_locale} : $this->name; return $limit > 0 ? str_limit($name, $limit) : $name; }
php
public function getDisplayName($locale = '', $limit = 0) { $locale = $locale ?: app()->getLocale(); $property_with_locale = $locale === 'en' ? "name" : "name_$locale"; $name = property_exists($this, $property_with_locale) ? $this->{$property_with_locale} : $this->name; return $limit > 0 ? str_limit($name, $limit) : $name; }
[ "public", "function", "getDisplayName", "(", "$", "locale", "=", "''", ",", "$", "limit", "=", "0", ")", "{", "$", "locale", "=", "$", "locale", "?", ":", "app", "(", ")", "->", "getLocale", "(", ")", ";", "$", "property_with_locale", "=", "$", "lo...
Get display name. @param string $locale @param int $limit @return mixed
[ "Get", "display", "name", "." ]
46774dbfef61131cf8f3fd9a2ab5c2ef4fccd6be
https://github.com/Lecturize/Laravel-Taxonomies/blob/46774dbfef61131cf8f3fd9a2ab5c2ef4fccd6be/src/Models/Term.php#L75-L84
train
Lecturize/Laravel-Taxonomies
src/Models/Term.php
Term.getRouteParameters
public function getRouteParameters($taxonomy) { $taxonomy = Taxonomy::taxonomy($taxonomy) ->term($this->name) ->with('parent') ->first(); $parameters = $this->getParentSlugs($taxonomy); array_push($parameters, $taxonomy->taxonomy); return array_reverse($parameters); }
php
public function getRouteParameters($taxonomy) { $taxonomy = Taxonomy::taxonomy($taxonomy) ->term($this->name) ->with('parent') ->first(); $parameters = $this->getParentSlugs($taxonomy); array_push($parameters, $taxonomy->taxonomy); return array_reverse($parameters); }
[ "public", "function", "getRouteParameters", "(", "$", "taxonomy", ")", "{", "$", "taxonomy", "=", "Taxonomy", "::", "taxonomy", "(", "$", "taxonomy", ")", "->", "term", "(", "$", "this", "->", "name", ")", "->", "with", "(", "'parent'", ")", "->", "fir...
Get route parameters. @param string $taxonomy @return mixed
[ "Get", "route", "parameters", "." ]
46774dbfef61131cf8f3fd9a2ab5c2ef4fccd6be
https://github.com/Lecturize/Laravel-Taxonomies/blob/46774dbfef61131cf8f3fd9a2ab5c2ef4fccd6be/src/Models/Term.php#L92-L104
train
Lecturize/Laravel-Taxonomies
src/Models/Term.php
Term.getParentSlugs
function getParentSlugs(Taxonomy $taxonomy, $parameters = []) { array_push($parameters, $taxonomy->term->slug); if (($parents = $taxonomy->parent()) && ($parent = $parents->first())) return $this->getParentSlugs($parent, $parameters); return $parameters; }
php
function getParentSlugs(Taxonomy $taxonomy, $parameters = []) { array_push($parameters, $taxonomy->term->slug); if (($parents = $taxonomy->parent()) && ($parent = $parents->first())) return $this->getParentSlugs($parent, $parameters); return $parameters; }
[ "function", "getParentSlugs", "(", "Taxonomy", "$", "taxonomy", ",", "$", "parameters", "=", "[", "]", ")", "{", "array_push", "(", "$", "parameters", ",", "$", "taxonomy", "->", "term", "->", "slug", ")", ";", "if", "(", "(", "$", "parents", "=", "$...
Get slugs of parent terms. @param Taxonomy $taxonomy @param array $parameters @return array
[ "Get", "slugs", "of", "parent", "terms", "." ]
46774dbfef61131cf8f3fd9a2ab5c2ef4fccd6be
https://github.com/Lecturize/Laravel-Taxonomies/blob/46774dbfef61131cf8f3fd9a2ab5c2ef4fccd6be/src/Models/Term.php#L113-L121
train
thecodingmachine/mouf
src-dev/Mouf/Controllers/SearchController.php
SearchController.defaultAction
public function defaultAction($query, $selfedit = "false") { $this->selfedit = $selfedit; $this->query = $query; /*if ($selfedit == "true") {*/ $this->moufManager = MoufManager::getMoufManager(); /*} else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); }*/ $this->searchUrls = array(); foreach ($this->searchService->searchableServices as $service) { /* @var $service MoufSearchable */ $this->searchUrls[] = array("name"=>$service->getSearchModuleName(), "url"=>ROOT_URL.$this->moufManager->findInstanceName($service)."/search"); } $this->contentBlock->addFile(ROOT_PATH."src-dev/views/search/results.php", $this); $this->template->toHtml(); }
php
public function defaultAction($query, $selfedit = "false") { $this->selfedit = $selfedit; $this->query = $query; /*if ($selfedit == "true") {*/ $this->moufManager = MoufManager::getMoufManager(); /*} else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); }*/ $this->searchUrls = array(); foreach ($this->searchService->searchableServices as $service) { /* @var $service MoufSearchable */ $this->searchUrls[] = array("name"=>$service->getSearchModuleName(), "url"=>ROOT_URL.$this->moufManager->findInstanceName($service)."/search"); } $this->contentBlock->addFile(ROOT_PATH."src-dev/views/search/results.php", $this); $this->template->toHtml(); }
[ "public", "function", "defaultAction", "(", "$", "query", ",", "$", "selfedit", "=", "\"false\"", ")", "{", "$", "this", "->", "selfedit", "=", "$", "selfedit", ";", "$", "this", "->", "query", "=", "$", "query", ";", "/*if ($selfedit == \"true\") {*/", "$...
Performs a full-text search in Mouf. @Action @Logged @param string $query The text to search. @param string $selfedit If true, the name of the component must be a component from the Mouf framework itself (internal use only)
[ "Performs", "a", "full", "-", "text", "search", "in", "Mouf", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/SearchController.php#L70-L88
train
thecodingmachine/mouf
src/Mouf/Validator/CheckConstructorLoopValidator.php
CheckConstructorLoopValidator.validateClass
public static function validateClass() { $moufManager = MoufManager::getMoufManager(); try { $moufManager->checkConstructorLoop(); return new MoufValidatorResult(MoufValidatorResult::SUCCESS, "No loop detected in constructor arguments."); } catch(MoufException $e) { return new MoufValidatorResult(MoufValidatorResult::ERROR, '<b>'.$e->getMessage().'</b><br /><br /> Please check yours instances to refactor your code and change your code architecture.<br /> The other ugly solution is to make a setter for one of this parameter to remove it from constructor argument'); } }
php
public static function validateClass() { $moufManager = MoufManager::getMoufManager(); try { $moufManager->checkConstructorLoop(); return new MoufValidatorResult(MoufValidatorResult::SUCCESS, "No loop detected in constructor arguments."); } catch(MoufException $e) { return new MoufValidatorResult(MoufValidatorResult::ERROR, '<b>'.$e->getMessage().'</b><br /><br /> Please check yours instances to refactor your code and change your code architecture.<br /> The other ugly solution is to make a setter for one of this parameter to remove it from constructor argument'); } }
[ "public", "static", "function", "validateClass", "(", ")", "{", "$", "moufManager", "=", "MoufManager", "::", "getMoufManager", "(", ")", ";", "try", "{", "$", "moufManager", "->", "checkConstructorLoop", "(", ")", ";", "return", "new", "MoufValidatorResult", ...
Check all constructor arguments to detect a loop @return MoufValidatorResult
[ "Check", "all", "constructor", "arguments", "to", "detect", "a", "loop" ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Validator/CheckConstructorLoopValidator.php#L18-L30
train
thecodingmachine/mouf
src/Mouf/Reflection/TypeDescriptor.php
TypeDescriptor.isPrimitiveTypesOrRecursiveArrayOfPrimitiveTypes
public function isPrimitiveTypesOrRecursiveArrayOfPrimitiveTypes() { if ($this->isPrimitiveType()) { return true; } if ($this->subType) { return $this->subType->isPrimitiveTypesOrRecursiveArrayOfPrimitiveTypes(); } return false; }
php
public function isPrimitiveTypesOrRecursiveArrayOfPrimitiveTypes() { if ($this->isPrimitiveType()) { return true; } if ($this->subType) { return $this->subType->isPrimitiveTypesOrRecursiveArrayOfPrimitiveTypes(); } return false; }
[ "public", "function", "isPrimitiveTypesOrRecursiveArrayOfPrimitiveTypes", "(", ")", "{", "if", "(", "$", "this", "->", "isPrimitiveType", "(", ")", ")", "{", "return", "true", ";", "}", "if", "(", "$", "this", "->", "subType", ")", "{", "return", "$", "thi...
Returns true if the type passed in parameter is primitive or an array of primitive type or an array of array of primitive type, etc... @param string $type @return bool
[ "Returns", "true", "if", "the", "type", "passed", "in", "parameter", "is", "primitive", "or", "an", "array", "of", "primitive", "type", "or", "an", "array", "of", "array", "of", "primitive", "type", "etc", "..." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/TypeDescriptor.php#L246-L254
train
thecodingmachine/mouf
src/Mouf/Reflection/TypeDescriptor.php
TypeDescriptor.isCompatible
public function isCompatible($value) { // If null, we are compatible if ($value === null) { return true; } // If the value passed is an array if (is_array($value)) { // Let's check if this type is an array. if (!$this->isArray()) { return false; } if (!$this->isAssociativeArray()) { // Let's check if the array passed in parameter has string values as keys. foreach ($value as $key=>$val) { if (is_string($key)) { return false; } } } // Now, let's test each subkey for compatibility foreach ($value as $key=>$val) { if (!$this->subType->isCompatible($val)) { return false; } } return true; } elseif ($value instanceof MoufInstanceDescriptor) { // Let's check if the instance descriptor is compatible with our type. if ($this->isPrimitiveType()) { return false; } if ($this->type == "array") { return false; } $classDescriptor = $value->getClassDescriptor(); if (ltrim($this->type,'\\') == ltrim($classDescriptor->getName(), '\\')) { return true; } //$type = new MoufReflectionClass($this->getType()); $result = $classDescriptor->isSubclassOf($this->getType()); return $result; } else { // The value is a primitive type. if ($this->isPrimitiveType()) { return true; } else { return false; } } }
php
public function isCompatible($value) { // If null, we are compatible if ($value === null) { return true; } // If the value passed is an array if (is_array($value)) { // Let's check if this type is an array. if (!$this->isArray()) { return false; } if (!$this->isAssociativeArray()) { // Let's check if the array passed in parameter has string values as keys. foreach ($value as $key=>$val) { if (is_string($key)) { return false; } } } // Now, let's test each subkey for compatibility foreach ($value as $key=>$val) { if (!$this->subType->isCompatible($val)) { return false; } } return true; } elseif ($value instanceof MoufInstanceDescriptor) { // Let's check if the instance descriptor is compatible with our type. if ($this->isPrimitiveType()) { return false; } if ($this->type == "array") { return false; } $classDescriptor = $value->getClassDescriptor(); if (ltrim($this->type,'\\') == ltrim($classDescriptor->getName(), '\\')) { return true; } //$type = new MoufReflectionClass($this->getType()); $result = $classDescriptor->isSubclassOf($this->getType()); return $result; } else { // The value is a primitive type. if ($this->isPrimitiveType()) { return true; } else { return false; } } }
[ "public", "function", "isCompatible", "(", "$", "value", ")", "{", "// If null, we are compatible", "if", "(", "$", "value", "===", "null", ")", "{", "return", "true", ";", "}", "// If the value passed is an array", "if", "(", "is_array", "(", "$", "value", ")...
Returns true if this type is compatible with the propertyDescriptor's value passed in parameter. @param string|array|MoufInstanceDescriptor|MoufInstanceDescriptor[] $instanceDescriptor @return bool
[ "Returns", "true", "if", "this", "type", "is", "compatible", "with", "the", "propertyDescriptor", "s", "value", "passed", "in", "parameter", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/TypeDescriptor.php#L263-L313
train
thecodingmachine/mouf
src-dev/Mouf/Controllers/ConfigController.php
ConfigController.index
public function index($selfedit = "false", $validation = null) { $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } //$this->constantsList = $this->moufManager->getConfigManager()->getDefinedConstants(); $this->constantsList = $this->moufManager->getConfigManager()->getMergedConstants(); $this->contentBlock->addFile(ROOT_PATH."src-dev/views/constants/displayConstantsList.php", $this); $this->template->toHtml(); }
php
public function index($selfedit = "false", $validation = null) { $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } //$this->constantsList = $this->moufManager->getConfigManager()->getDefinedConstants(); $this->constantsList = $this->moufManager->getConfigManager()->getMergedConstants(); $this->contentBlock->addFile(ROOT_PATH."src-dev/views/constants/displayConstantsList.php", $this); $this->template->toHtml(); }
[ "public", "function", "index", "(", "$", "selfedit", "=", "\"false\"", ",", "$", "validation", "=", "null", ")", "{", "$", "this", "->", "selfedit", "=", "$", "selfedit", ";", "if", "(", "$", "selfedit", "==", "\"true\"", ")", "{", "$", "this", "->",...
Displays the list of defined parameters in config.php @Action @Logged @param string $selfedit If true, the name of the component must be a component from the Mouf framework itself (internal use only) @param string $validation The validation message to display (either null, or confirmok).
[ "Displays", "the", "list", "of", "defined", "parameters", "in", "config", ".", "php" ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/ConfigController.php#L73-L86
train
thecodingmachine/mouf
src-dev/Mouf/Controllers/ConfigController.php
ConfigController.saveConfig
public function saveConfig($selfedit = "false") { $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } $this->configManager = $this->moufManager->getConfigManager(); $this->constantsList = $this->configManager->getMergedConstants(); $constants = array(); foreach ($this->constantsList as $key=>$def) { if ($def['defined'] == true && $def['type'] == 'bool') { $constants[$key] = (get($key)=="true")?true:false; } else { $constants[$key] = get($key); } } $this->configManager->setDefinedConstants($constants); header("Location: .?selfedit=".$selfedit); }
php
public function saveConfig($selfedit = "false") { $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } $this->configManager = $this->moufManager->getConfigManager(); $this->constantsList = $this->configManager->getMergedConstants(); $constants = array(); foreach ($this->constantsList as $key=>$def) { if ($def['defined'] == true && $def['type'] == 'bool') { $constants[$key] = (get($key)=="true")?true:false; } else { $constants[$key] = get($key); } } $this->configManager->setDefinedConstants($constants); header("Location: .?selfedit=".$selfedit); }
[ "public", "function", "saveConfig", "(", "$", "selfedit", "=", "\"false\"", ")", "{", "$", "this", "->", "selfedit", "=", "$", "selfedit", ";", "if", "(", "$", "selfedit", "==", "\"true\"", ")", "{", "$", "this", "->", "moufManager", "=", "MoufManager", ...
The action to save the configuration. @Action @Logged @Post
[ "The", "action", "to", "save", "the", "configuration", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/ConfigController.php#L95-L118
train