idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
49,900 | private function getFileMap ( PackageInterface $ package , $ directory ) { $ files = [ ] ; $ root = $ this -> getInstallPath ( $ package ) ; if ( ! file_exists ( $ root . '/' . $ directory ) ) { return [ ] ; } $ iterator = new RecursiveDirectoryIterator ( $ root . '/' . $ directory , RecursiveDirectoryIterator :: SKIP_DOTS ) ; foreach ( new RecursiveIteratorIterator ( $ iterator , RecursiveIteratorIterator :: CHILD_FIRST ) as $ file ) { if ( $ file -> isFile ( ) ) { $ path = str_replace ( $ root . '/' . $ directory . '/' , '' , $ file -> getPathname ( ) ) ; $ files [ $ directory . '/' . $ path ] = $ path ; } } return $ files ; } | Generate a file map from the passed directory . |
49,901 | public function dump ( ) { if ( empty ( $ this -> files ) ) { return ; } $ buffer = <<<'PHP'<?php$runonce = function(array $files, $delete = false) { foreach ($files as $file) { try { include $file; } catch (\Exception $e) {} $relpath = str_replace(TL_ROOT . DIRECTORY_SEPARATOR, '', $file); if ($delete && !unlink($file)) { throw new \Exception( 'The file ' . $relpath . ' cannot be deleted. ' . 'Please remove the file manually and correct the file permission settings on your server.' ); } }};PHP ; if ( file_exists ( $ this -> targetFile ) ) { if ( ! is_writable ( $ this -> targetFile ) || ! is_file ( $ this -> targetFile ) ) { throw new \ RuntimeException ( sprintf ( 'Runonce file "%s" exists but is not writable.' , $ this -> targetFile ) ) ; } $ current = str_replace ( '.php' , '_' . substr ( md5 ( mt_rand ( ) ) , 0 , 8 ) . '.php' , $ this -> targetFile ) ; $ this -> filesystem -> rename ( $ this -> targetFile , $ current ) ; $ buffer .= "\n\$runonce(array('" . $ current . "'), true);\n" ; } $ buffer .= "\n\$runonce(" . var_export ( array_unique ( $ this -> files ) , true ) . ");\n" ; $ this -> filesystem -> ensureDirectoryExists ( dirname ( $ this -> targetFile ) ) ; if ( false === file_put_contents ( $ this -> targetFile , $ buffer ) ) { throw new \ RuntimeException ( sprintf ( 'Could not write runonce file to "%s"' , $ this -> targetFile ) ) ; } $ this -> files = [ ] ; } | Dumps runonce file to the target file given in the constructor . |
49,902 | public function lintFile ( $ file , OutputInterface $ output ) { $ manager = new Manager ( ) ; $ settings = new Settings ( ) ; $ settings -> addPaths ( [ $ file ] ) ; ob_start ( ) ; $ result = $ manager -> run ( $ settings ) ; $ buffer = ob_get_contents ( ) ; ob_end_clean ( ) ; if ( $ result -> hasError ( ) ) { $ output -> writeln ( '<error>Syntax error was found in config.php after it was updated.</error>' ) ; $ output -> writeln ( [ '<error>Review the PHP Lint report for more details:</error>' , '' , $ buffer ] ) ; } return $ result -> hasError ( ) ? 1 : 0 ; } | Check a single file for PHP syntax errors . |
49,903 | private function runProcesses ( OutputInterface $ output ) { $ progress = new ProgressIndicator ( $ output ) ; $ progress -> start ( 'Starting...' ) ; foreach ( $ this -> processes as $ process ) { $ process -> start ( ) ; $ progress -> advance ( ) ; } foreach ( $ this -> processes as $ name => $ process ) { $ progress -> setMessage ( sprintf ( 'Waiting for moodle-plugin-ci %s...' , $ name ) ) ; while ( $ process -> isRunning ( ) ) { $ progress -> advance ( ) ; } } $ progress -> finish ( 'Done!' ) ; } | Run the processes in parallel . |
49,904 | private function reportOnProcesses ( InputInterface $ input , OutputInterface $ output ) { $ style = new SymfonyStyle ( $ input , $ output ) ; $ result = 0 ; foreach ( $ this -> processes as $ name => $ process ) { $ style -> newLine ( ) ; echo $ process -> getOutput ( ) ; if ( ! $ process -> isSuccessful ( ) ) { $ result = 1 ; $ style -> error ( sprintf ( 'Command %s failed' , $ name ) ) ; } $ errorOutput = $ process -> getErrorOutput ( ) ; if ( ! empty ( $ errorOutput ) ) { $ style -> error ( sprintf ( 'Error output for %s command' , $ name ) ) ; $ style -> writeln ( $ errorOutput ) ; } } return $ result ; } | Report on the completed processes . |
49,905 | public function checkOutputForProblems ( ) { if ( ! $ this -> isStarted ( ) ) { throw new \ LogicException ( sprintf ( 'Process must be started before calling %s.' , __FUNCTION__ ) ) ; } if ( $ this -> isOutputDisabled ( ) ) { throw new \ LogicException ( 'Output has been disabled, cannot verify if Moodle script ran without problems' ) ; } if ( $ this -> hasPhpErrorMessages ( $ this -> getErrorOutput ( ) ) ) { throw new MoodlePhpException ( $ this ) ; } if ( $ this -> hasDebuggingMessages ( $ this -> getOutput ( ) ) ) { throw new MoodleDebugException ( $ this ) ; } } | Checks to make sure that there are no problems with the output . |
49,906 | public function installPluginIntoMoodle ( MoodlePlugin $ plugin ) { $ this -> getOutput ( ) -> info ( sprintf ( 'Installing %s' , $ plugin -> getComponent ( ) ) ) ; $ directory = $ this -> moodle -> getComponentInstallDirectory ( $ plugin -> getComponent ( ) ) ; if ( is_dir ( $ directory ) ) { throw new \ RuntimeException ( 'Plugin is already installed in standard Moodle' ) ; } $ this -> getOutput ( ) -> info ( sprintf ( 'Copying plugin from %s to %s' , $ plugin -> directory , $ directory ) ) ; $ filesystem = new Filesystem ( ) ; $ filesystem -> mirror ( $ plugin -> directory , $ directory ) ; return $ directory ; } | Install the plugin into Moodle . |
49,907 | public function createConfigFile ( $ toFile ) { if ( file_exists ( $ toFile ) ) { $ this -> getOutput ( ) -> debug ( 'Config file already exists in plugin, skipping creation of config file.' ) ; return ; } if ( ! $ this -> configDumper -> hasConfig ( ) ) { $ this -> getOutput ( ) -> debug ( 'No config to write out, skipping creation of config file.' ) ; return ; } $ this -> configDumper -> dump ( $ toFile ) ; $ this -> getOutput ( ) -> debug ( 'Created config file at ' . $ toFile ) ; } | Create plugin config file . |
49,908 | protected function behatTagsFactory ( array $ tags ) { $ fileTokens = [ ] ; $ files = Finder :: create ( ) -> files ( ) -> in ( $ this -> plugin -> directory ) -> path ( 'tests/behat' ) -> name ( '*.feature' ) -> getIterator ( ) ; foreach ( $ files as $ file ) { $ fileTokens [ ] = FileTokens :: create ( $ file -> getRelativePathname ( ) ) -> mustHaveAll ( $ tags ) ; } return $ fileTokens ; } | Factory method for generating FileTokens instances for all feature files in a plugin . |
49,909 | public function addMessagesFromTokens ( $ type , FileTokens $ fileTokens ) { foreach ( $ fileTokens -> tokens as $ token ) { if ( $ token -> hasTokenBeenFound ( ) ) { $ this -> addSuccess ( sprintf ( 'In %s, found %s %s' , $ fileTokens -> file , $ type , implode ( ' OR ' , $ token -> tokens ) ) ) ; } else { $ this -> addError ( sprintf ( 'In %s, failed to find %s %s' , $ fileTokens -> file , $ type , implode ( ' OR ' , $ token -> tokens ) ) ) ; } } } | Add messages about finding or not finding tokens in a file . |
49,910 | public function verifyRequirements ( ) { $ this -> findRequiredFiles ( $ this -> requirements -> getRequiredFiles ( ) ) ; $ this -> findRequiredTokens ( new FunctionFinder ( ) , $ this -> requirements -> getRequiredFunctions ( ) ) ; $ this -> findRequiredTokens ( new ClassFinder ( ) , $ this -> requirements -> getRequiredClasses ( ) ) ; $ this -> findRequiredTokens ( new LangFinder ( ) , [ $ this -> requirements -> getRequiredStrings ( ) ] ) ; $ this -> findRequiredTokens ( new CapabilityFinder ( ) , [ $ this -> requirements -> getRequiredCapabilities ( ) ] ) ; $ this -> findRequiredTokens ( new TableFinder ( ) , [ $ this -> requirements -> getRequiredTables ( ) ] ) ; $ this -> findRequiredTokens ( new TablePrefixFinder ( ) , [ $ this -> requirements -> getRequiredTablePrefix ( ) ] ) ; $ this -> findRequiredTokens ( new BehatTagFinder ( ) , $ this -> requirements -> getRequiredBehatTags ( ) ) ; } | Run verification of a plugin . |
49,911 | public function findRequiredFiles ( array $ files ) { foreach ( $ files as $ file ) { if ( file_exists ( $ this -> plugin -> directory . '/' . $ file ) ) { $ this -> addSuccess ( sprintf ( 'Found required file: %s' , $ file ) ) ; } else { $ this -> addError ( sprintf ( 'Failed to find required file: %s' , $ file ) ) ; } } } | Ensure a list of files exists . |
49,912 | public function findRequiredTokens ( FinderInterface $ finder , array $ tokenCollection ) { foreach ( $ tokenCollection as $ fileTokens ) { if ( ! $ fileTokens -> hasTokens ( ) ) { continue ; } $ file = $ this -> plugin -> directory . '/' . $ fileTokens -> file ; if ( ! file_exists ( $ file ) ) { $ this -> addWarning ( sprintf ( 'Skipping validation of missing or optional file: %s' , $ fileTokens -> file ) ) ; continue ; } try { $ finder -> findTokens ( $ file , $ fileTokens ) ; $ this -> addMessagesFromTokens ( $ finder -> getType ( ) , $ fileTokens ) ; } catch ( \ Exception $ e ) { $ this -> addError ( $ e -> getMessage ( ) ) ; } } } | Find required tokens in a file . |
49,913 | public function parse ( $ string , Banking \ Mt940 \ Engine $ engine = null ) { if ( ! empty ( $ string ) ) { if ( $ engine === null ) { $ engine = Banking \ Mt940 \ Engine :: __getInstance ( $ string ) ; } $ this -> engine = $ engine ; if ( $ this -> engine instanceof Banking \ Mt940 \ Engine ) { $ this -> engine -> loadString ( $ string ) ; return $ this -> engine -> parse ( ) ; } } return [ ] ; } | Parse the given string into an array of Banking \ Statement objects . |
49,914 | public function getStash ( ? string $ key = null ) { $ content = json_decode ( file_get_contents ( $ this -> temp ( ) ) , true ) ; return $ key ? ( isset ( $ content [ $ key ] ) ? $ content [ $ key ] : null ) : $ content ; } | Retrieve the contents of the relevant file . |
49,915 | protected function startServer ( ) : void { $ this -> guardServerStarting ( ) ; $ this -> process = new Process ( $ this -> prepareCommand ( ) ) ; $ this -> process -> setWorkingDirectory ( $ this -> laravelPublicPath ( ) ) ; $ this -> process -> start ( ) ; } | Start the server . Execute the command and open a pointer to it . Tuck away the output as it s not relevant for us during our testing . |
49,916 | protected function guardServerStarting ( ) { if ( $ socket = @ fsockopen ( $ this -> host , $ this -> port , $ errorNumber = 0 , $ errorString = '' , $ timeout = 1 ) ) { fclose ( $ socket ) ; throw new UnableToStartServer ( $ this -> host . ':' . $ this -> port ) ; } } | Verify that there isn t an existing server on the host and port that we want to use . Sometimes a server can be left oped when PHP drops out or the user may have another service running . |
49,917 | protected function prepareCommand ( ) : string { return sprintf ( ( ( $ this -> isWindows ( ) ? '' : 'exec ' ) . '%s -S %s:%s %s' ) , ( new PhpExecutableFinder ( ) ) -> find ( false ) , $ this -> host , $ this -> port , __DIR__ . '/server.php' ) ; } | Prepare the command for starting the PHP server . |
49,918 | protected function setUpTheBrowserEnvironment ( ) { Browser :: $ baseUrl = $ this -> baseUrl ( ) ; $ this -> prepareDirectories ( ) ; Browser :: $ userResolver = function ( ) { return $ this -> user ( ) ; } ; } | Setup the browser environment . |
49,919 | protected function prepareDirectories ( ) { $ tests = $ this -> resolveBrowserTestsPath ( ) ; foreach ( [ '/screenshots' , '/console' ] as $ dir ) { if ( ! is_dir ( $ tests . $ dir ) ) { mkdir ( $ tests . $ dir , 0777 , true ) ; } } Browser :: $ storeScreenshotsAt = $ tests . '/screenshots' ; Browser :: $ storeConsoleLogAt = $ tests . '/console' ; } | Ensure the directories we need for dusk exist and set them for the Browser to use . |
49,920 | public static function __getInstance ( $ string ) { $ engine = self :: detectBank ( $ string ) ; $ engine -> loadString ( $ string ) ; return $ engine ; } | reads the firstline of the string to guess which engine to use for parsing . |
49,921 | public static function registerEngine ( $ engineClass , $ priority ) { if ( ! is_int ( $ priority ) ) { trigger_error ( 'Priority must be integer' , E_USER_WARNING ) ; return ; } if ( array_key_exists ( $ priority , self :: $ registeredEngines ) ) { trigger_error ( 'Priority already taken' , E_USER_WARNING ) ; return ; } if ( ! class_exists ( $ engineClass ) ) { trigger_error ( 'Engine does not exist' , E_USER_WARNING ) ; return ; } self :: $ registeredEngines [ $ priority ] = $ engineClass ; } | Register a new Engine . |
49,922 | protected function parseStatementAccount ( ) { $ results = [ ] ; if ( preg_match ( '/:25:([\d\.]+)*/' , $ this -> getCurrentStatementData ( ) , $ results ) && ! empty ( $ results [ 1 ] ) ) { return $ this -> sanitizeAccount ( $ results [ 1 ] ) ; } if ( preg_match ( '/:25:([A-Z0-9]{8}[\d\.]+)*/' , $ this -> getCurrentStatementData ( ) , $ results ) && ! empty ( $ results [ 1 ] ) ) { return $ this -> sanitizeAccount ( $ results [ 1 ] ) ; } return '' ; } | uses field 25 to gather accoutnumber . |
49,923 | protected function parseStatementPrice ( $ key ) { $ results = [ ] ; if ( preg_match ( '/:' . $ key . ':([CD])?.*[A-Z]{3}([\d,\.]+)*/' , $ this -> getCurrentStatementData ( ) , $ results ) && ! empty ( $ results [ 2 ] ) ) { $ sanitizedPrice = $ this -> sanitizePrice ( $ results [ 2 ] ) ; return ( ! empty ( $ results [ 1 ] ) && $ results [ 1 ] === 'D' ) ? - $ sanitizedPrice : $ sanitizedPrice ; } return '' ; } | The actual pricing parser for statements . |
49,924 | protected function parseStatementNumber ( ) { $ results = [ ] ; if ( preg_match ( '/:28C?:(.*)/' , $ this -> getCurrentStatementData ( ) , $ results ) && ! empty ( $ results [ 1 ] ) ) { return trim ( $ results [ 1 ] ) ; } return '' ; } | uses the 28C field to determine the statement number . |
49,925 | protected function parseTransactionDebitCredit ( ) { $ results = [ ] ; if ( preg_match ( '/^:61:\d+([CD])\d+/' , $ this -> getCurrentTransactionData ( ) , $ results ) && ! empty ( $ results [ 1 ] ) ) { return $ this -> sanitizeDebitCredit ( $ results [ 1 ] ) ; } return '' ; } | uses the 61 field to determine debit or credit of the transaction . |
49,926 | protected function parseTransactionDescription ( ) { $ results = [ ] ; if ( preg_match_all ( '/[\n]:86:(.*?)(?=\n(:6([12]))|$)/s' , $ this -> getCurrentTransactionData ( ) , $ results ) && ! empty ( $ results [ 1 ] ) ) { return $ this -> sanitizeDescription ( implode ( PHP_EOL , $ results [ 1 ] ) ) ; } return '' ; } | uses the 86 field to determine retrieve the full description of the transaction . |
49,927 | protected function parseTransactionCode ( ) { $ results = [ ] ; if ( preg_match ( '/^:61:.*?N(.{3}).*/' , $ this -> getCurrentTransactionData ( ) , $ results ) && ! empty ( $ results [ 1 ] ) ) { return trim ( $ results [ 1 ] ) ; } return '' ; } | uses the 61 field to get the bank specific transaction code . |
49,928 | public static function serve ( $ host = '127.0.0.1' , $ port = 8000 ) : void { static :: stopServing ( ) ; $ server = new DuskServer ( $ host , $ port ) ; $ server -> stash ( [ 'class' => static :: class ] ) ; $ server -> start ( ) ; static :: $ server = $ server ; } | Begin serving on a given host and port . |
49,929 | public function tweakApplication ( Closure $ closure ) : void { $ closure ( $ this -> app ) ; static :: $ server -> stash ( [ 'class' => static :: class , 'tweakApplication' => serialize ( SerializableClosure :: from ( $ closure ) ) , ] ) ; } | Make tweaks to the application both inside the test and on the test server . |
49,930 | public function getFreshApplicationToServe ( DuskServer $ server ) { static :: $ server = $ server ; $ this -> setUpDuskServer ( ) ; $ serializedClosure = static :: $ server -> getStash ( 'tweakApplication' ) ; if ( $ serializedClosure ) { $ closure = unserialize ( $ serializedClosure ) -> getClosure ( ) ; $ closure ( $ this -> app ) ; } return $ this -> app ; } | Build up a fresh application to serve intended for use when we want to replicate the Application state during a Dusk test when we start our test server . See the main server file server . php . |
49,931 | public function getAll ( LibraryType $ library , string $ dir = '/' ) { $ clippedBaseUri = $ this -> clipUri ( $ this -> client -> getConfig ( 'base_uri' ) ) ; $ response = $ this -> client -> request ( 'GET' , $ clippedBaseUri . '/repos/' . $ library -> id . '/dir/' , [ 'query' => [ 'p' => $ dir ] , ] ) ; $ json = json_decode ( ( string ) $ response -> getBody ( ) ) ; $ dirItemCollection = [ ] ; foreach ( $ json as $ dirItemJson ) { $ dirItem = ( new DirectoryItem ) -> fromJson ( $ dirItemJson ) ; if ( $ dirItem -> dir === '/' ) { $ dirItem = $ dirItem -> fromArray ( [ 'dir' => $ dir ] ) ; } $ dirItemCollection [ ] = $ dirItem ; } return $ dirItemCollection ; } | Get all items of a directory in a library |
49,932 | public function get ( $ key ) { if ( isset ( $ this -> store [ $ key ] ) ) { return filter_var ( $ this -> store [ $ key ] , FILTER_SANITIZE_STRING ) ; } return filter_input ( INPUT_COOKIE , $ key , FILTER_SANITIZE_STRING ) ; } | Get cookie with FILTER_SANITIZE_STRING |
49,933 | public function getInt ( $ key ) { if ( isset ( $ this -> store [ $ key ] ) ) { return ( int ) filter_var ( $ this -> store [ $ key ] , FILTER_SANITIZE_NUMBER_INT ) ; } return ( int ) filter_input ( INPUT_COOKIE , $ key , FILTER_SANITIZE_NUMBER_INT ) ; } | Get cookie with FILTER_SANITIZE_NUMBER_INT |
49,934 | public function clear ( $ key ) { setcookie ( $ key , '' , time ( ) - 3600 ) ; unset ( $ _COOKIE [ $ key ] ) ; unset ( $ this -> store [ $ key ] ) ; return $ this ; } | Unset the key from the cookie |
49,935 | public function toArray ( int $ mode = self :: ARRAY_ASSOC ) : array { switch ( $ mode ) { case self :: ARRAY_MULTI_PART : $ caseHelper = CaseHelperFactory :: make ( CaseHelperFactory :: INPUT_TYPE_CAMEL_CASE ) ; $ keyVals = $ this -> toArray ( self :: ARRAY_ASSOC ) ; $ multiPart = [ ] ; foreach ( $ keyVals as $ key => $ val ) { $ multiPart [ ] = [ 'name' => $ caseHelper -> toSnakeCase ( $ key ) , 'contents' => "$val" ] ; } $ array = $ multiPart ; break ; default : $ array = array_filter ( ( array ) $ this ) ; break ; } return $ array ; } | Return instance as array |
49,936 | public function getAll ( ) : array { $ response = $ this -> client -> request ( 'GET' , $ this -> client -> getConfig ( 'base_uri' ) . '/shared-links/' ) ; $ json = json_decode ( $ response -> getBody ( ) ) ; $ sharedLinksCollection = [ ] ; foreach ( $ json -> fileshares as $ sharedLink ) { $ sharedLinksCollection [ ] = ( new SharedLinkType ) -> fromJson ( $ sharedLink ) ; } return $ sharedLinksCollection ; } | List shared links |
49,937 | public function remove ( SharedLinkType $ sharedLinkType ) : bool { $ uri = sprintf ( '%s/shared-links/?t=%s' , $ this -> clipUri ( $ this -> client -> getConfig ( 'base_uri' ) ) , basename ( $ sharedLinkType -> url ) ) ; $ response = $ this -> client -> request ( 'DELETE' , $ uri , [ 'headers' => [ 'Accept' => 'application/json' ] , ] ) ; return $ response -> getStatusCode ( ) === 200 ; } | Remove shared link |
49,938 | public function create ( LibraryType $ library , string $ path , int $ expire = null , string $ shareType = SharedLinkType :: SHARE_TYPE_DOWNLOAD , string $ password = null ) : ? SharedLinkType { $ uri = sprintf ( '%s/repos/%s/file/shared-link/' , $ this -> clipUri ( $ this -> client -> getConfig ( 'base_uri' ) ) , $ library -> id ) ; $ multiPartParams = [ [ 'name' => 'p' , 'contents' => $ path ] , [ 'name' => 'share_type' , 'contents' => $ shareType ] , ] ; if ( ! is_null ( $ expire ) ) { $ multiPartParams [ ] = [ 'name' => 'expire' , 'contents' => "$expire" ] ; } if ( ! is_null ( $ password ) ) { $ multiPartParams [ ] = [ 'name' => 'password' , 'contents' => $ password ] ; } $ response = $ this -> client -> request ( 'PUT' , $ uri , [ 'headers' => [ 'Accept' => 'application/json' ] , 'multipart' => $ multiPartParams , ] ) ; if ( $ response -> getStatusCode ( ) !== 201 || $ response -> hasHeader ( 'Location' ) === false ) { return null ; } $ url = $ response -> getHeader ( 'Location' ) [ 0 ] ; return ( new SharedLinkType ) -> fromArray ( [ 'url' => $ url , 'expire' => $ expire , 'password' => $ password , 'path' => $ path , 'shareType' => $ shareType , ] ) ; } | Create share link |
49,939 | public function prepareResponse ( $ result ) { $ response = [ 'header' => null , 'content' => null ] ; $ d = "\r\n\r\n" ; if ( is_string ( $ result ) && strpos ( $ result , $ d ) !== false ) { list ( $ header , $ content ) = explode ( $ d , $ result , 2 ) ; if ( stripos ( $ header , '100 Continue' ) !== false && strpos ( $ content , $ d ) !== false ) { list ( $ header , $ content ) = explode ( $ d , $ content , 2 ) ; } $ response [ 'header' ] = $ header ; $ response [ 'content' ] = htmlentities ( $ content ) ; } return $ response ; } | Process the result and split into headers and content |
49,940 | public function getContactId ( ) { if ( $ mtcId = $ this -> getInt ( self :: MTC_ID ) ) { return $ mtcId ; } elseif ( $ mauticSessionId = $ this -> getSessionId ( ) ) { return $ this -> getInt ( $ mauticSessionId ) ; } return null ; } | Get Mautic Contact ID from Cookie |
49,941 | public function unsetContactId ( ) { $ this -> clear ( self :: MTC_ID ) ; if ( $ sessionId = $ this -> getSessionId ( ) ) { $ this -> clear ( $ sessionId ) ; } return $ this ; } | Unet Mautic Contact ID cookies |
49,942 | public function getSessionId ( ) { if ( $ mauticSessionId = $ this -> get ( self :: MAUTIC_SESSION_ID ) ) { return $ mauticSessionId ; } if ( $ mauticSessionId = $ this -> get ( self :: MTC_SID ) ) { return $ mauticSessionId ; } return null ; } | Returns Mautic session ID if it exists in the cookie |
49,943 | public function setSessionId ( $ sessionId ) { $ this -> set ( self :: MAUTIC_SESSION_ID , $ sessionId ) ; $ this -> set ( self :: MTC_SID , $ sessionId ) ; return $ this ; } | Set Mautic Session ID cookies |
49,944 | public function unsetSessionId ( ) { $ this -> clear ( self :: MAUTIC_SESSION_ID ) ; $ this -> clear ( self :: MTC_SID ) ; return $ this ; } | Unset Mautic Session ID cookies |
49,945 | public function getAll ( ) : array { $ response = $ this -> client -> request ( 'GET' , $ this -> resourceUri ) ; $ json = json_decode ( ( string ) $ response -> getBody ( ) ) ; $ dirItemCollection = [ ] ; foreach ( $ json as $ starredFile ) { $ dirItemCollection [ ] = ( new DirectoryItem ) -> fromJson ( $ starredFile ) ; } return $ dirItemCollection ; } | Get all starred files |
49,946 | public function unstar ( LibraryType $ library , DirectoryItem $ dirItem ) : bool { $ uri = sprintf ( '%s/?repo_id=%s&p=%s' , $ this -> resourceUri , $ library -> id , $ dirItem -> path ) ; $ response = $ this -> client -> request ( 'DELETE' , $ uri ) ; return $ response -> getStatusCode ( ) === 200 ; } | Unstar a file |
49,947 | public function move ( LibraryType $ srcLibrary , array $ srcPaths , LibraryType $ dstLibrary , string $ dstDirectoryPath ) : bool { return $ this -> copy ( $ srcLibrary , $ srcPaths , $ dstLibrary , $ dstDirectoryPath , self :: OPERATION_MOVE ) ; } | Move multiple files or folders |
49,948 | public function copy ( LibraryType $ srcLibrary , array $ srcPaths , LibraryType $ dstLibrary , string $ dstDirectoryPath , int $ operation = self :: OPERATION_COPY ) : bool { if ( empty ( $ srcPaths ) || empty ( $ dstDirectoryPath ) ) { return false ; } $ operationMode = $ operation === self :: OPERATION_MOVE ? 'move' : 'copy' ; $ srcFolderPath = dirname ( $ srcPaths [ 0 ] ) ; $ dstFileNames = $ this -> preparePaths ( $ srcFolderPath , $ srcPaths ) ; if ( empty ( $ dstFileNames ) ) { return false ; } $ srcFolderPath = str_replace ( "\\" , "/" , $ srcFolderPath ) ; $ uri = sprintf ( '%s/repos/%s/fileops/%s/?p=%s' , $ this -> clipUri ( $ this -> client -> getConfig ( 'base_uri' ) ) , $ srcLibrary -> id , $ operationMode , $ srcFolderPath ) ; $ response = $ this -> client -> request ( 'POST' , $ uri , [ 'headers' => [ 'Accept' => 'application/json' ] , 'multipart' => [ [ 'name' => 'file_names' , 'contents' => $ dstFileNames , ] , [ 'name' => 'dst_repo' , 'contents' => $ dstLibrary -> id , ] , [ 'name' => 'dst_dir' , 'contents' => $ dstDirectoryPath , ] , ] , ] ) ; return $ response -> getStatusCode ( ) === 200 ; } | Copy multiple files or folders |
49,949 | protected function preparePaths ( string $ folder , array $ paths , string $ fileNames = '' ) : string { foreach ( $ paths as $ path ) { if ( dirname ( $ path ) != $ folder ) { return '' ; } if ( $ fileNames != '' ) { $ fileNames .= ':' ; } $ fileNames .= basename ( $ path ) ; } return $ fileNames ; } | check source folders paths and build the file_names string |
49,950 | public function delete ( LibraryType $ library , array $ paths ) : bool { if ( empty ( $ paths ) ) { return false ; } $ folderPath = dirname ( $ paths [ 0 ] ) ; $ fileNames = $ this -> preparePaths ( $ folderPath , $ paths ) ; if ( empty ( $ fileNames ) ) { return false ; } $ folderPath = str_replace ( "\\" , "/" , $ folderPath ) ; $ uri = sprintf ( '%s/repos/%s/fileops/delete/?p=%s' , $ this -> clipUri ( $ this -> client -> getConfig ( 'base_uri' ) ) , $ library -> id , $ folderPath ) ; $ response = $ this -> client -> request ( 'POST' , $ uri , [ 'headers' => [ 'Accept' => 'application/json' ] , 'multipart' => [ [ 'name' => 'file_names' , 'contents' => $ fileNames , ] , ] , ] ) ; return $ response -> getStatusCode ( ) === 200 ; } | Delete multiple files or folders |
49,951 | public function getUserAvatarByEmail ( string $ emailAddress , int $ size = 80 ) { return $ this -> getUserAvatar ( ( new AccountType ) -> fromArray ( [ 'email' => $ emailAddress ] ) , $ size ) ; } | Get user avatar by email address |
49,952 | protected function getAvatar ( Type $ type , int $ size ) { if ( ! is_int ( $ size ) || $ size < 1 ) { throw new \ Exception ( 'Illegal avatar size' ) ; } switch ( true ) { case ( $ type instanceof GroupType ) : $ id = $ type -> id ; $ resource = 'group' ; break ; case ( $ type instanceof AccountType ) : $ id = $ type -> email ; $ resource = 'user' ; break ; default : throw new \ Exception ( 'Unsupported type to retrieve avatar information for.' ) ; } $ response = $ this -> client -> get ( $ this -> client -> getConfig ( 'base_uri' ) . '/avatars/' . $ resource . '/' . $ id . '/resized/' . $ size . '/' ) ; $ json = json_decode ( $ response -> getBody ( ) ) ; return ( new AvatarType ) -> fromJson ( $ json ) ; } | Get avatar image |
49,953 | public function createUserAvatar ( AccountType $ accountType ) : bool { $ uri = sprintf ( '%s/accounts/' . $ accountType -> email . '/' , $ this -> clipUri ( $ this -> client -> getConfig ( 'base_uri' ) ) ) ; $ response = $ this -> client -> put ( $ uri , [ 'headers' => [ 'Accept' => 'application/json; charset=utf-8' ] , 'multipart' => $ accountType -> toArray ( Type :: ARRAY_MULTI_PART ) , ] ) ; return $ response -> getStatusCode ( ) === 201 ; } | Create a new user avatar |
49,954 | private function parse ( $ headers ) { foreach ( preg_split ( '/\r\n|\r|\n/' , $ headers ) as $ i => $ line ) { if ( $ i === 0 ) { $ this -> headers [ 'http_code' ] = $ line ; } else { list ( $ key , $ value ) = explode ( ': ' , $ line ) ; if ( $ key === 'Set-Cookie' ) { list ( $ textCookie ) = explode ( ';' , $ value ) ; list ( $ cookieKey , $ cookieValue ) = explode ( '=' , $ textCookie ) ; $ this -> cookies [ $ cookieKey ] = $ cookieValue ; } else { $ this -> headers [ $ key ] = $ value ; } } } } | Parse text headers and fills in cookies and headers properites |
49,955 | public function getByEmail ( string $ emailAddress ) : AccountType { $ response = $ this -> client -> request ( 'GET' , $ this -> client -> getConfig ( 'base_uri' ) . '/accounts/' . $ emailAddress . '/' ) ; $ json = json_decode ( $ response -> getBody ( ) ) ; return ( new AccountType ) -> fromJson ( $ json ) ; } | Get AccountType instance by email address |
49,956 | public function getPreparseFieldsContent ( Element $ element , string $ eventHandle ) { $ content = [ ] ; $ fieldLayout = $ element -> getFieldLayout ( ) ; if ( $ fieldLayout ) { foreach ( $ fieldLayout -> getFields ( ) as $ field ) { if ( $ field && \ get_class ( $ field ) === 'aelvan\preparsefield\fields\PreparseFieldType' ) { $ isBeforeSave = ( $ eventHandle === 'onBeforeSave' ) ; $ parseBeforeSave = ( bool ) $ field -> parseBeforeSave ; if ( $ isBeforeSave === $ parseBeforeSave ) { $ fieldValue = $ this -> parseField ( $ field , $ element ) ; if ( $ fieldValue !== null ) { $ content [ $ field -> handle ] = $ fieldValue ; } } } } } return $ content ; } | Loops over fields in element to determine if they have preparse fields . |
49,957 | public function shouldParseElementOnMove ( Element $ element ) : bool { $ fieldLayout = $ element -> getFieldLayout ( ) ; if ( $ fieldLayout ) { foreach ( $ fieldLayout -> getFields ( ) as $ field ) { if ( $ field && \ get_class ( $ field ) === 'aelvan\preparsefield\fields\PreparseFieldType' ) { $ parseOnMove = $ field -> parseOnMove ; if ( $ parseOnMove ) { return true ; } } } } return false ; } | Checks to see if an element has a prepase field that should be saved on move |
49,958 | public function getById ( $ libraryId ) : LibraryType { $ response = $ this -> client -> request ( 'GET' , $ this -> client -> getConfig ( 'base_uri' ) . '/repos/' . $ libraryId . '/' ) ; $ json = json_decode ( $ response -> getBody ( ) ) ; return ( new LibraryType ) -> fromJson ( $ json ) ; } | Get library info |
49,959 | public function exists ( $ value , $ attribute = 'name' ) : bool { $ libraries = $ this -> getAll ( ) ; foreach ( $ libraries as $ lib ) { if ( isset ( $ lib -> { $ attribute } ) && $ lib -> { $ attribute } === $ value ) { return true ; } } return false ; } | Check if library with certain attribute value exists |
49,960 | public function create ( $ name , $ description = "new repo" , $ password = '' ) : bool { if ( empty ( $ name ) ) { return false ; } if ( $ this -> exists ( $ name ) ) { return false ; } $ uri = sprintf ( '%s/repos/' , $ this -> clipUri ( $ this -> client -> getConfig ( 'base_uri' ) ) ) ; $ multipartData = [ [ 'name' => 'name' , 'contents' => $ name , ] , [ 'name' => 'desc' , 'contents' => $ description , ] , ] ; if ( $ password !== '' ) { $ multipartData [ ] = [ 'name' => 'passwd' , 'contents' => $ password , ] ; } $ response = $ this -> client -> request ( 'POST' , $ uri , [ 'headers' => [ 'Accept' => 'application/json' ] , 'multipart' => $ multipartData , ] ) ; return $ response -> getStatusCode ( ) === 200 ; } | Create a new library |
49,961 | public function remove ( $ libraryId ) : bool { if ( empty ( $ libraryId ) ) { return false ; } $ uri = sprintf ( '%s/repos/%s/' , $ this -> clipUri ( $ this -> client -> getConfig ( 'base_uri' ) ) , $ libraryId ) ; $ response = $ this -> client -> request ( 'DELETE' , $ uri , [ 'headers' => [ 'Accept' => 'application/json' ] , ] ) ; return $ response -> getStatusCode ( ) === 200 ; } | Remove a library |
49,962 | public function sharePersonal ( $ libraryId , array $ users , string $ permission = Resource :: PERMISSION_R ) : bool { $ uri = sprintf ( '%s/shared-repos/%s/?share_type=personal&users=%s&permission=%s' , $ this -> clipUri ( $ this -> client -> getConfig ( 'base_uri' ) ) , $ libraryId , join ( ',' , $ users ) , $ permission ) ; $ response = $ this -> client -> put ( $ uri ) ; return $ response -> getStatusCode ( ) === 200 ; } | Share a library share type is always personal |
49,963 | private function areNullableReturnTypesSupported ( ) : bool { $ testVersion = trim ( PHPCompatibility \ PHPCSHelper :: getConfigData ( 'testVersion' ) ? : '' ) ; if ( ! $ testVersion ) { return false ; } preg_match ( '`^(\d+\.\d+)(?:\s*-\s*(?:\d+\.\d+)?)?$`' , $ testVersion , $ matches ) ; $ min = $ matches [ 1 ] ?? null ; return $ min && version_compare ( $ min , '7.1' , '>=' ) ; } | Return true if _min_ supported version is PHP 7 . 1 . |
49,964 | public function downloadFromDir ( LibraryType $ library , DirectoryItem $ item , string $ localFilePath , string $ dir , int $ reuse = 1 ) : Response { if ( is_readable ( $ localFilePath ) ) { throw new Exception ( 'File already exists' ) ; } $ downloadUrl = $ this -> getDownloadUrl ( $ library , $ item , $ dir , $ reuse ) ; return $ this -> client -> request ( 'GET' , $ downloadUrl , [ 'save_to' => $ localFilePath ] ) ; } | Get download URL of a file from a Directory item |
49,965 | public function getUploadUrl ( LibraryType $ library , bool $ newFile = true ) { $ url = $ this -> client -> getConfig ( 'base_uri' ) . '/repos/' . $ library -> id . '/' . ( $ newFile ? 'upload' : 'update' ) . '-link/' ; $ response = $ this -> client -> request ( 'GET' , $ url ) ; $ uploadLink = ( string ) $ response -> getBody ( ) ; return preg_replace ( "/\"/" , '' , $ uploadLink ) ; } | Get upload URL |
49,966 | public function getFileDetail ( LibraryType $ library , string $ remoteFilePath ) : DirectoryItem { $ url = $ this -> client -> getConfig ( 'base_uri' ) . '/repos/' . $ library -> id . '/file/detail/' . '?p=' . $ this -> urlEncodePath ( $ remoteFilePath ) ; $ response = $ this -> client -> request ( 'GET' , $ url ) ; $ json = json_decode ( ( string ) $ response -> getBody ( ) ) ; return ( new DirectoryItem ) -> fromJson ( $ json ) ; } | Get file detail |
49,967 | public function getFileRevisionDownloadUrl ( LibraryType $ library , DirectoryItem $ dirItem , FileHistoryItem $ fileHistoryItem ) { $ url = $ this -> client -> getConfig ( 'base_uri' ) . '/repos/' . $ library -> id . '/file/revision/' . '?p=' . $ this -> urlEncodePath ( $ dirItem -> path . $ dirItem -> name ) . '&commit_id=' . $ fileHistoryItem -> id ; $ response = $ this -> client -> request ( 'GET' , $ url ) ; return preg_replace ( "/\"/" , '' , ( string ) $ response -> getBody ( ) ) ; } | Get file revision download URL |
49,968 | public function downloadRevision ( LibraryType $ library , DirectoryItem $ dirItem , FileHistoryItem $ fileHistoryItem , string $ localFilePath ) : Response { $ downloadUrl = $ this -> getFileRevisionDownloadUrl ( $ library , $ dirItem , $ fileHistoryItem ) ; return $ this -> client -> request ( 'GET' , $ downloadUrl , [ 'save_to' => $ localFilePath ] ) ; } | Download file revision |
49,969 | public function getHistory ( LibraryType $ library , DirectoryItem $ item ) { $ url = $ this -> client -> getConfig ( 'base_uri' ) . '/repos/' . $ library -> id . '/file/history/' . '?p=' . $ this -> urlEncodePath ( $ item -> path . $ item -> name ) ; $ response = $ this -> client -> request ( 'GET' , $ url ) ; $ json = json_decode ( $ response -> getBody ( ) ) ; $ fileHistoryCollection = [ ] ; foreach ( $ json -> commits as $ lib ) { $ fileHistoryCollection [ ] = ( new FileHistoryItem ) -> fromJson ( $ lib ) ; } return $ fileHistoryCollection ; } | Get history of a file DirectoryItem |
49,970 | public function create ( LibraryType $ library , DirectoryItem $ item ) : bool { if ( empty ( $ item -> path ) || empty ( $ item -> name ) ) { return false ; } $ uri = sprintf ( '%s/repos/%s/file/?p=%s' , $ this -> clipUri ( $ this -> client -> getConfig ( 'base_uri' ) ) , $ library -> id , $ this -> urlEncodePath ( $ item -> path . $ item -> name ) ) ; $ response = $ this -> client -> request ( 'POST' , $ uri , [ 'headers' => [ 'Accept' => 'application/json' ] , 'multipart' => [ [ 'name' => 'operation' , 'contents' => 'create' , ] , ] , ] ) ; return $ response -> getStatusCode ( ) === 201 ; } | Create empty file on Seafile server |
49,971 | public function getInfoStartAsync ( $ filePath ) { $ mediaInfoCommandBuilder = new MediaInfoCommandBuilder ( ) ; $ this -> mediaInfoCommandRunnerAsync = $ mediaInfoCommandBuilder -> buildMediaInfoCommandRunner ( $ filePath , $ this -> configuration ) ; $ this -> mediaInfoCommandRunnerAsync -> start ( ) ; } | Call to start asynchronous process . |
49,972 | protected function updateUserFields ( UserInterface $ user ) { if ( null === $ this -> userDiscriminator ) { $ this -> userDiscriminator = $ this -> container -> get ( 'rollerworks_multi_user.user_discriminator' ) ; } if ( null === $ this -> userDiscriminator -> getCurrentUser ( ) || true !== $ this -> userDiscriminator -> getCurrentUserConfig ( ) -> getConfig ( 'use_listener' , true ) ) { return ; } if ( null === $ this -> userManager ) { $ this -> userManager = $ this -> container -> get ( 'fos_user.user_manager' ) ; } $ this -> userManager -> updateCanonicalFields ( $ user ) ; $ this -> userManager -> updatePassword ( $ user ) ; } | This must be called on prePersist and preUpdate if the event is about a user . |
49,973 | public function dispatchChangePasswordInitialize ( Event $ e ) { if ( $ userSys = $ this -> userDiscriminator -> getCurrentUser ( ) ) { $ this -> eventDispatcher -> dispatch ( $ userSys . '.change_password.edit.initialize' , $ e ) ; } } | last updated on 2014 - 03 - 06 |
49,974 | public static function getSubscribedEvents ( ) { return array ( FOSUserEvents :: CHANGE_PASSWORD_INITIALIZE => 'dispatchChangePasswordInitialize' , FOSUserEvents :: CHANGE_PASSWORD_SUCCESS => 'dispatchChangePasswordSuccess' , FOSUserEvents :: CHANGE_PASSWORD_COMPLETED => 'dispatchChangePasswordCompleted' , FOSUserEvents :: GROUP_CREATE_INITIALIZE => 'dispatchGroupCreateInitialize' , FOSUserEvents :: GROUP_CREATE_SUCCESS => 'dispatchGroupCreateSuccess' , FOSUserEvents :: GROUP_CREATE_COMPLETED => 'dispatchGroupCreateCompleted' , FOSUserEvents :: GROUP_DELETE_COMPLETED => 'dispatchGroupDeleteCompleted' , FOSUserEvents :: GROUP_EDIT_INITIALIZE => 'dispatchGroupEditInitialize' , FOSUserEvents :: GROUP_EDIT_SUCCESS => 'dispatchGroupEditSuccess' , FOSUserEvents :: GROUP_EDIT_COMPLETED => 'dispatchGroupEditCompleted' , FOSUserEvents :: PROFILE_EDIT_INITIALIZE => 'dispatchProfileEditInitialize' , FOSUserEvents :: PROFILE_EDIT_SUCCESS => 'dispatchProfileEditSuccess' , FOSUserEvents :: PROFILE_EDIT_COMPLETED => 'dispatchProfileEditCompleted' , FOSUserEvents :: REGISTRATION_INITIALIZE => 'dispatchRegistrationInitialize' , FOSUserEvents :: REGISTRATION_SUCCESS => 'dispatchRegistrationSuccess' , FOSUserEvents :: REGISTRATION_COMPLETED => 'dispatchRegistrationCompleted' , FOSUserEvents :: REGISTRATION_CONFIRM => 'dispatchRegistrationConfirm' , FOSUserEvents :: REGISTRATION_CONFIRMED => 'dispatchRegistrationConfirmed' , FOSUserEvents :: RESETTING_RESET_INITIALIZE => 'dispatchResettingResetInitialize' , FOSUserEvents :: RESETTING_RESET_SUCCESS => 'dispatchResettingResetSuccess' , FOSUserEvents :: RESETTING_RESET_COMPLETED => 'dispatchResettingResetCompleted' , FOSUserEvents :: SECURITY_IMPLICIT_LOGIN => 'dispatchSecurityImplicitLogin' , ) ; } | Subscribes to all events defined in FOS \ UserBundle \ FOSUserEvents . |
49,975 | private function createRequestMatcher ( ContainerBuilder $ container , $ path = null , $ host = null , $ methods = array ( ) , $ ip = null , array $ attributes = array ( ) ) { $ serialized = serialize ( array ( $ path , $ host , $ methods , $ ip , $ attributes ) ) ; $ id = 'rollerworks_multi_user.request_matcher.' . md5 ( $ serialized ) . sha1 ( $ serialized ) ; if ( isset ( $ this -> requestMatchers [ $ id ] ) ) { throw new \ RuntimeException ( sprintf ( 'There is already a request-matcher for this configuration: path: "%s", host: "%s". Only one request matcher should match for the user system.' , $ path , $ host ) ) ; } if ( $ methods ) { $ methods = array_map ( 'strtoupper' , ( array ) $ methods ) ; } $ arguments = array ( $ path , $ host , $ methods , $ ip , $ attributes ) ; while ( count ( $ arguments ) > 0 && ! end ( $ arguments ) ) { array_pop ( $ arguments ) ; } $ container -> register ( $ id , '%rollerworks_multi_user.matcher.class%' ) -> setPublic ( false ) -> setArguments ( $ arguments ) ; return $ this -> requestMatchers [ $ id ] = new Reference ( $ id ) ; } | Copied from the SymfonySecurityBundle . |
49,976 | public function wait ( ) { if ( $ this -> process == null ) { throw new \ Exception ( 'You must run `start` before running `wait`' ) ; } $ this -> process -> wait ( ) ; if ( ! $ this -> process -> isSuccessful ( ) ) { throw new \ RuntimeException ( $ this -> process -> getErrorOutput ( ) ) ; } return $ this -> process -> getOutput ( ) ; } | Blocks until call is complete . |
49,977 | private function loadServices ( array $ config , ContainerBuilder $ container ) { if ( 'fos_user.util.canonicalizer.default' === $ config [ 'service' ] [ 'username_canonicalizer' ] ) { $ config [ 'service' ] [ 'username_canonicalizer' ] = 'fos_user.util.username_canonicalizer' ; } if ( 'fos_user.util.canonicalizer.default' === $ config [ 'service' ] [ 'email_canonicalizer' ] ) { $ config [ 'service' ] [ 'email_canonicalizer' ] = 'fos_user.util.email_canonicalizer' ; } if ( 'fos_user.user_manager.default' === $ config [ 'service' ] [ 'user_manager' ] ) { $ config [ 'service' ] [ 'user_manager' ] = $ this -> createUserManager ( $ config , $ container ) ; } if ( sprintf ( '%s.user_manager' , $ this -> servicePrefix ) !== $ config [ 'service' ] [ 'user_manager' ] ) { $ container -> setAlias ( sprintf ( '%s.user_manager' , $ this -> servicePrefix ) , $ config [ 'service' ] [ 'user_manager' ] ) ; } $ container -> setDefinition ( sprintf ( '%s.user_provider.username' , $ this -> servicePrefix ) , new DefinitionDecorator ( 'fos_user.user_provider.username' ) ) -> replaceArgument ( 0 , new Reference ( sprintf ( '%s.user_manager' , $ this -> servicePrefix ) ) ) -> setPublic ( false ) ; $ container -> setDefinition ( sprintf ( '%s.user_provider.username_email' , $ this -> servicePrefix ) , new DefinitionDecorator ( 'fos_user.user_provider.username_email' ) ) -> replaceArgument ( 0 , new Reference ( sprintf ( '%s.user_manager' , $ this -> servicePrefix ) ) ) -> setPublic ( false ) ; $ container -> setDefinition ( sprintf ( '%s.user_manipulator' , $ this -> servicePrefix ) , new DefinitionDecorator ( 'fos_user.util.user_manipulator' ) ) -> replaceArgument ( 0 , new Reference ( sprintf ( '%s.user_manager' , $ this -> servicePrefix ) ) ) ; $ container -> setDefinition ( sprintf ( '%s.listener.authentication' , $ this -> servicePrefix ) , new DefinitionDecorator ( 'fos_user.listener.authentication' ) ) -> replaceArgument ( 1 , sprintf ( '%%%s.firewall_name%%' , $ this -> servicePrefix ) ) -> addTag ( 'kernel.event_subscriber' ) ; } | Loads the primary services . |
49,978 | public function setForm ( $ name , $ formName , $ type , array $ validationGroups ) { $ this -> forms [ $ name ] = array ( 'type' => $ type , 'name' => $ formName , 'validation_groups' => $ validationGroups ) ; return $ this ; } | Set the form configuration . |
49,979 | public function getFormType ( $ name ) { return isset ( $ this -> forms [ $ name ] [ 'type' ] ) ? $ this -> forms [ $ name ] [ 'type' ] : null ; } | Get the form - type name for the given config - name . |
49,980 | public function getFormName ( $ name ) { return isset ( $ this -> forms [ $ name ] [ 'name' ] ) ? $ this -> forms [ $ name ] [ 'name' ] : null ; } | Get the form name for the given config - name . |
49,981 | public function getFormValidationGroups ( $ name ) { return isset ( $ this -> forms [ $ name ] [ 'validation_groups' ] ) ? $ this -> forms [ $ name ] [ 'validation_groups' ] : null ; } | Get the validation groups for the given config - name . |
49,982 | public function getTemplate ( $ name ) { if ( ! isset ( $ this -> templates [ $ name ] ) ) { throw new MissingTemplateException ( sprintf ( 'Unable to get template for "%s", there is no such template configured.' , $ name ) ) ; } $ template = ( string ) $ this -> templates [ $ name ] ; if ( '' === $ template ) { throw new MissingTemplateException ( sprintf ( 'Unable to get template for "%s", it seems the template value is empty. Make sure you enabled the proper section and configured a proper value.' , $ name ) ) ; } return $ template ; } | Get the View template for the given config - name . |
49,983 | protected function getSkeletonDirs ( BundleInterface $ bundle = null ) { $ baseSkeletonDirs = parent :: getSkeletonDirs ( $ bundle ) ; $ skeletonDirs = array ( ) ; if ( is_dir ( $ dir = $ this -> getContainer ( ) -> get ( 'kernel' ) -> getRootdir ( ) . '/Resources/MultiUserBundleMultiUserBundle/skeleton' ) ) { $ skeletonDirs [ ] = $ dir ; } $ reflClass = new \ ReflectionClass ( $ this ) ; $ dir = dirname ( $ reflClass -> getFileName ( ) ) ; $ skeletonDirs [ ] = $ dir . '/../Resources/skeleton' ; $ skeletonDirs [ ] = $ dir . '/../Resources' ; return array_merge ( $ skeletonDirs , $ baseSkeletonDirs ) ; } | add this bundle skeleton dirs to the beginning of the parent skeletonDirs array . |
49,984 | protected function getPrepareCorsHeaders ( $ headers ) { if ( array_key_exists ( CorsResponseHeaders :: EXPOSE_HEADERS , $ headers ) === true ) { $ headers [ CorsResponseHeaders :: EXPOSE_HEADERS ] = implode ( ', ' , $ headers [ CorsResponseHeaders :: EXPOSE_HEADERS ] ) ; } return $ headers ; } | There is an issue with IE which cannot work with multiple Access - Control - Expose - Headers and requires it them to be comma separated . Chrome and Firefox seem to be not affected . |
49,985 | protected function mergeConfigs ( ) { $ repo = $ this -> getConfigRepository ( ) ; $ config = $ repo -> get ( static :: CONFIG_FILE_NAME_WO_EXT , [ ] ) ; $ base = $ this -> getBaseConfig ( ) ; $ result = $ config + $ base ; $ repo -> set ( static :: CONFIG_FILE_NAME_WO_EXT , $ result ) ; } | Merge default config and config from application config folder . |
49,986 | public static function encode_fn ( $ file , $ safe = true ) { if ( $ safe && preg_match ( '#^[a-zA-Z0-9/_\-.%]+$#' , $ file ) ) { return $ file ; } $ file = urlencode ( $ file ) ; $ file = str_replace ( '%2F' , '/' , $ file ) ; return $ file ; } | URL - Encode a filename to allow unicodecharacters |
49,987 | public static function is_ascii ( $ str ) { for ( $ i = 0 ; $ i < strlen ( $ str ) ; $ i ++ ) { if ( ord ( $ str { $ i } ) > 127 ) return false ; } return true ; } | Checks if a string contains 7bit ASCII only |
49,988 | public static function strip ( $ str ) { $ ascii = '' ; for ( $ i = 0 ; $ i < strlen ( $ str ) ; $ i ++ ) { if ( ord ( $ str { $ i } ) < 128 ) { $ ascii .= $ str { $ i } ; } } return $ ascii ; } | Strips all highbyte chars |
49,989 | public static function explode ( $ sep , $ str ) { if ( $ sep == '' ) { trigger_error ( 'Empty delimiter' , E_USER_WARNING ) ; return FALSE ; } return preg_split ( '!' . preg_quote ( $ sep , '!' ) . '!u' , $ str ) ; } | Unicode aware replacement for explode |
49,990 | public static function deaccent ( $ string , $ case = 0 ) { if ( $ case <= 0 ) { $ string = str_replace ( array_keys ( self :: $ utf8_lower_accents ) , array_values ( self :: $ utf8_lower_accents ) , $ string ) ; } if ( $ case >= 0 ) { $ string = str_replace ( array_keys ( self :: $ utf8_upper_accents ) , array_values ( self :: $ utf8_upper_accents ) , $ string ) ; } return $ string ; } | Replace accented UTF - 8 characters by unaccented ASCII - 7 equivalents |
49,991 | public static function strpos ( $ haystack , $ needle , $ offset = 0 ) { if ( ! defined ( 'UTF8_NOMBSTRING' ) && function_exists ( 'mb_strpos' ) ) return mb_strpos ( $ haystack , $ needle , $ offset , 'utf-8' ) ; if ( ! $ offset ) { $ ar = self :: explode ( $ needle , $ haystack ) ; if ( count ( $ ar ) > 1 ) { return self :: strlen ( $ ar [ 0 ] ) ; } return false ; } else { if ( ! is_int ( $ offset ) ) { trigger_error ( 'Offset must be an integer' , E_USER_WARNING ) ; return false ; } $ str = self :: substr ( $ haystack , $ offset ) ; if ( false !== ( $ pos = self :: strpos ( $ str , $ needle ) ) ) { return $ pos + $ offset ; } return false ; } } | This is an Unicode aware replacement for strpos |
49,992 | public static function tohtml ( $ str ) { $ ret = '' ; $ max = strlen ( $ str ) ; $ last = 0 ; for ( $ i = 0 ; $ i < $ max ; $ i ++ ) { $ c = $ str { $ i } ; $ c1 = ord ( $ c ) ; if ( $ c1 >> 5 == 6 ) { $ ret .= substr ( $ str , $ last , $ i - $ last ) ; $ c1 &= 31 ; $ c2 = ord ( $ str { ++ $ i } ) ; $ c2 &= 63 ; $ c2 |= ( ( $ c1 & 3 ) << 6 ) ; $ c1 >>= 2 ; $ ret .= '&#' . ( $ c1 * 100 + $ c2 ) . ';' ; $ last = $ i + 1 ; } } return $ ret . substr ( $ str , $ last , $ i ) ; } | Encodes UTF - 8 characters to HTML entities |
49,993 | protected function rv ( ) { $ length = Utf8 :: strlen ( $ this -> word ) ; $ this -> rv = '' ; $ this -> rvIndex = $ length ; for ( $ i = 0 ; $ i < $ length ; $ i ++ ) { $ letter = Utf8 :: substr ( $ this -> word , $ i , 1 ) ; if ( in_array ( $ letter , self :: $ vowels ) ) { $ this -> rv = Utf8 :: substr ( $ this -> word , ( $ i + 1 ) ) ; $ this -> rvIndex = $ i + 1 ; return true ; } } return false ; } | In any word RV is the region after the first vowel or the end of the word if it contains no vowel . |
49,994 | private function step2 ( ) { if ( $ this -> searchIfInR1 ( array ( 'dd' , 'gd' , 'nn' , 'dt' , 'gt' , 'kt' , 'tt' ) ) !== false ) { $ this -> word = Utf8 :: substr ( $ this -> word , 0 , - 1 ) ; } } | Step 2 Search for one of the following suffixes in R1 and if found delete the last letter . |
49,995 | private function step0 ( ) { $ this -> word = preg_replace ( '#([q])u#u' , '$1U' , $ this -> word ) ; $ this -> word = preg_replace ( '#([' . $ this -> plainVowels . '])y#u' , '$1Y' , $ this -> word ) ; $ this -> word = preg_replace ( '#y([' . $ this -> plainVowels . '])#u' , 'Y$1' , $ this -> word ) ; $ this -> word = preg_replace ( '#([' . $ this -> plainVowels . '])u([' . $ this -> plainVowels . '])#u' , '$1U$2' , $ this -> word ) ; $ this -> word = preg_replace ( '#([' . $ this -> plainVowels . '])i([' . $ this -> plainVowels . '])#u' , '$1I$2' , $ this -> word ) ; } | Assume the word is in lower case . Then put into upper case u or i preceded and followed by a vowel and y preceded or followed by a vowel . u after q is also put into upper case . For example jouer - > joUer ennuie - > ennuIe yeux - > Yeux quand - > qUand |
49,996 | private function hasValidSEnding ( $ word ) { $ lastLetter = Utf8 :: substr ( $ word , - 1 , 1 ) ; if ( in_array ( $ lastLetter , array ( 'b' , 'c' , 'd' , 'f' , 'g' , 'h' , 'j' , 'l' , 'm' , 'n' , 'o' , 'p' , 'r' , 't' , 'v' , 'y' , 'z' ) ) ) { return true ; } if ( $ lastLetter == 'k' ) { $ beforeLetter = Utf8 :: substr ( $ word , - 2 , 1 ) ; if ( ! in_array ( $ beforeLetter , self :: $ vowels ) ) { return true ; } } return false ; } | Define a valid s - ending as one of b c d f g h j l m n o p r t v y z or k not preceded by a vowel |
49,997 | private function step1 ( ) { if ( ( $ position = $ this -> searchIfInR1 ( array ( 'erte' , 'ert' ) ) ) !== false ) { $ this -> word = preg_replace ( '#(erte|ert)$#u' , 'er' , $ this -> word ) ; return true ; } if ( ( $ position = $ this -> searchIfInR1 ( array ( 'hetenes' , 'hetene' , 'hetens' , 'heten' , 'endes' , 'heter' , 'ande' , 'ende' , 'enes' , 'edes' , 'ede' , 'ane' , 'ene' , 'het' , 'ers' , 'ets' , 'ast' , 'ens' , 'en' , 'ar' , 'er' , 'as' , 'es' , 'et' , 'a' , 'e' ) ) ) !== false ) { $ this -> word = Utf8 :: substr ( $ this -> word , 0 , $ position ) ; return true ; } if ( ( $ position = $ this -> searchIfInR1 ( array ( 's' ) ) ) !== false ) { $ word = Utf8 :: substr ( $ this -> word , 0 , $ position ) ; if ( $ this -> hasValidSEnding ( $ word ) ) { $ this -> word = $ word ; } return true ; } } | Step 1 Search for the longest among the following suffixes in R1 and perform the action indicated . |
49,998 | private function hasValidSEnding ( $ word ) { $ lastLetter = Utf8 :: substr ( $ word , - 1 , 1 ) ; return ! in_array ( $ lastLetter , array_merge ( self :: $ vowels , array ( 'j' ) ) ) ; } | Define a valid s - ending as a non - vowel other than j . |
49,999 | private function hasValidEnEnding ( $ word ) { $ lastLetter = Utf8 :: substr ( $ word , - 1 , 1 ) ; if ( in_array ( $ lastLetter , self :: $ vowels ) ) { return false ; } $ threeLastLetters = Utf8 :: substr ( $ word , - 3 , 3 ) ; if ( $ threeLastLetters == 'gem' ) { return false ; } return true ; } | Define a valid en - ending as a non - vowel and not gem . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.