idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
26,000 | protected function getDrupalUuid ( ) { $ uuid = null ; $ version = $ this -> getProjectVersion ( ) ; if ( $ version >= 8 ) { $ result = $ this -> runDrushCommand ( 'cget system.site uuid' , true ) ; if ( $ result -> getExitCode ( ) === ResultData :: EXITCODE_OK ) { $ message = $ result -> getMessage ( ) ; if ( $ colon_pos = strrpos ( $ message , ':' ) ) { $ uuid = trim ( substr ( $ message , $ colon_pos + 1 ) ) ; } } } return $ uuid ; } | Get Drupal UUID . |
26,001 | protected function saveDrupalUuid ( ) { $ config = ProjectX :: getProjectConfig ( ) ; $ options [ static :: getTypeId ( ) ] = [ 'build_info' => [ 'uuid' => $ this -> getDrupalUuid ( ) ] ] ; $ config -> setOptions ( $ options ) -> save ( ProjectX :: getProjectPath ( ) ) ; return $ this ; } | Save Drupal UUID to configuration . |
26,002 | protected function drushInstallCommonStack ( $ executable , $ drupal_root , DatabaseInterface $ database ) { $ options = $ this -> getInstallOptions ( ) ; $ db_user = $ database -> getUser ( ) ; $ db_port = $ database -> getPort ( ) ; $ db_pass = $ database -> getPassword ( ) ; $ db_name = $ database -> getDatabase ( ) ; $ db_host = $ database -> getHostname ( ) ; $ db_protocol = $ database -> getProtocol ( ) ; return $ this -> taskDrushStack ( $ executable ) -> drupalRootDirectory ( $ drupal_root ) -> siteName ( $ options [ 'site' ] [ 'name' ] ) -> accountMail ( $ options [ 'account' ] [ 'mail' ] ) -> accountName ( $ options [ 'account' ] [ 'name' ] ) -> accountPass ( $ options [ 'account' ] [ 'pass' ] ) -> dbUrl ( "$db_protocol://$db_user:$db_pass@$db_host:$db_port/$db_name" ) -> siteInstall ( $ options [ 'site' ] [ 'profile' ] ) ; } | Drush install common command . |
26,003 | protected function drushAliasFileContent ( $ name , $ uri , $ root , array $ options = [ ] , $ include_opentag = true ) { $ name = Utility :: machineName ( $ name ) ; $ content = $ include_opentag ? "<?php\n\n" : '' ; $ content .= "\$aliases['$name'] = [" ; $ content .= "\n\t'uri' => '$uri'," ; $ content .= "\n\t'root' => '$root'," ; if ( isset ( $ options [ 'remote_host' ] ) && $ remote_host = $ options [ 'remote_host' ] ) { $ content .= "\n\t'remote-host' => '$remote_host'," ; } if ( isset ( $ options [ 'remote_user' ] ) && $ remote_user = $ options [ 'remote_user' ] ) { $ content .= "\n\t'remote-user' => '$remote_user'," ; } $ content .= "\n\t'path-aliases' => [" ; $ content .= "\n\t\t'%dump-dir' => '/tmp'," ; $ content .= "\n\t]" ; $ content .= "\n];" ; return $ content ; } | Drupal alias PHP file content . |
26,004 | protected function setupDrupalSettingsLocalInclude ( ) { $ this -> taskWriteToFile ( $ this -> settingFile ) -> append ( ) -> appendUnlessMatches ( '/if.+\/settings\.local\.php.+{\n.+\n\}/' , $ this -> drupalSettingsLocalInclude ( ) ) -> run ( ) ; return $ this ; } | Setup Drupal settings local include . |
26,005 | public function upload ( $ id , array $ files ) { foreach ( $ this -> uploaders as $ uploader ) { if ( ! $ uploader -> upload ( $ id , $ files ) ) { return false ; } } return true ; } | Uploads via all defined uploaders |
26,006 | protected function getDockerfileVariables ( ) { if ( $ os_packages = $ this -> getInfoProperty ( 'packages' ) ) { $ this -> mergeConfigVariable ( 'PACKAGE_INSTALL' , $ os_packages ) ; } if ( $ pecl_packages = $ this -> getInfoProperty ( 'pecl_packages' ) ) { $ this -> mergeConfigVariable ( 'PHP_PECL' , $ pecl_packages ) ; } if ( $ php_extensions = $ this -> getInfoProperty ( 'extensions' ) ) { $ this -> mergeConfigVariable ( 'PHP_EXT_INSTALL' , $ php_extensions ) ; } if ( $ php_command = $ this -> getInfoProperty ( 'commands' ) ) { $ this -> mergeConfigVariable ( 'PHP_COMMANDS' , $ php_command ) ; } return $ this -> processDockerfileVariables ( ) ; } | Get dockerfile variables . |
26,007 | protected function processDockerfileVariables ( ) { $ variables = [ ] ; $ variables [ 'PHP_VERSION' ] = $ this -> getVersion ( ) ; foreach ( $ this -> configs as $ key => $ values ) { if ( ! in_array ( $ key , static :: DOCKER_VARIABLES ) ) { continue ; } if ( $ key === 'PHP_EXT_ENABLE' && ! empty ( $ this -> configs [ 'PHP_PECL' ] ) ) { $ php_pecl = $ this -> configs [ 'PHP_PECL' ] ; array_walk ( $ php_pecl , function ( & $ name ) { $ pos = strpos ( $ name , ':' ) ; if ( $ pos !== false ) { $ name = substr ( $ name , 0 , $ pos ) ; } } ) ; $ values = array_merge ( $ php_pecl , $ values ) ; } if ( empty ( $ values ) ) { continue ; } $ variables [ $ key ] = $ this -> formatVariables ( $ key , $ values ) ; } return $ variables ; } | Process dockerfile variables . |
26,008 | protected function formatVariables ( $ key , array $ values ) { switch ( $ key ) { case 'PHP_PECL' : return $ this -> formatPeclPackages ( $ values ) ; case 'PHP_COMMANDS' : return $ this -> formatRunCommand ( $ values ) ; case 'PHP_EXT_CONFIG' : case 'PHP_EXT_ENABLE' : case 'PHP_EXT_INSTALL' : case 'PACKAGE_INSTALL' : return $ this -> formatValueDelimiter ( $ values ) ; } } | Format docker variables . |
26,009 | protected function formatPeclPackages ( array $ values ) { $ packages = [ ] ; foreach ( $ values as $ package ) { list ( $ name , $ version ) = strpos ( $ package , ':' ) !== false ? explode ( ':' , $ package ) : [ $ package , null ] ; if ( $ name === 'xdebug' && ! isset ( $ version ) ) { $ version = version_compare ( $ this -> getVersion ( ) , 7.0 , '<' ) ? '2.5.5' : null ; } $ version = isset ( $ version ) ? "-{$version}" : null ; $ packages [ ] = "pecl install {$name}{$version} \\" ; } if ( empty ( $ packages ) ) { return null ; } return "&& " . implode ( "\r\n && " , $ packages ) ; } | Format PECL packages . |
26,010 | protected function generateLocationAuth ( string $ authTicket , float $ latitude , float $ longitude , float $ altitude = 0.0 ) { $ seed = hexdec ( xxhash32 ( $ authTicket , 0x1B845238 ) ) ; return ( int ) hexdec ( xxhash32 ( $ this -> getLocationBytes ( $ latitude , $ longitude , $ altitude ) , ( int ) $ seed ) ) ; } | Generate location auth hash |
26,011 | protected function generateLocation ( float $ latitude , float $ longitude , float $ altitude = 0.0 ) : int { return ( int ) hexdec ( xxhash32 ( $ this -> getLocationBytes ( $ latitude , $ longitude , $ altitude ) , 0x1B845238 ) ) ; } | Generate location hash |
26,012 | protected function generateRequestHash ( string $ authTicket , string $ request ) : int { $ seed = ( unpack ( "J" , pack ( "H*" , xxhash64 ( $ authTicket , 0x1B845238 ) ) ) ) [ 1 ] ; return ( unpack ( "J" , pack ( "H*" , xxhash64 ( $ request , $ seed ) ) ) ) [ 1 ] ; } | Generate request hash |
26,013 | protected function getLocationBytes ( float $ latitude , float $ longitude , float $ altitude ) : string { return Hex :: d2h ( $ latitude ) . Hex :: d2h ( $ longitude ) . Hex :: d2h ( $ altitude ) ; } | Get the location as bytes |
26,014 | public static function build ( $ pdo , $ table ) { $ configMapper = new ConfigMapper ( new Serializer ( ) , $ pdo , $ table ) ; return new SqlConfigService ( $ configMapper , new ArrayConfig ( ) ) ; } | Builds configuration service |
26,015 | public function destroy ( $ id ) { $ this -> guardAgainstMissingParent ( 'destroy' ) ; $ this -> shopify -> delete ( $ this -> path ( $ id ) ) ; } | Destroy the specified resource . |
26,016 | protected function requiresParent ( string $ methodName ) { if ( in_array ( '*' , $ this -> requiresParent ) ) { return true ; } return in_array ( $ methodName , $ this -> requiresParent ) ; } | Check if the action requires a parent resource . |
26,017 | protected function getGitRepositoryFor ( $ path ) { $ git = new GitRepository ( $ this -> determineGitRoot ( $ path ) ) ; if ( $ this -> output -> getVerbosity ( ) >= OutputInterface :: VERBOSITY_DEBUG ) { $ git -> getConfig ( ) -> setLogger ( new ConsoleLogger ( $ this -> output ) ) ; } return $ git ; } | Create a git repository instance . |
26,018 | private function getAllFilesFromGit ( $ git ) { $ gitDir = $ git -> getRepositoryPath ( ) ; $ arguments = [ $ git -> getConfig ( ) -> getGitExecutablePath ( ) , 'ls-tree' , 'HEAD' , '-r' , '--full-name' , '--name-only' ] ; $ process = new Process ( $ this -> prepareProcessArguments ( $ arguments ) , $ git -> getRepositoryPath ( ) ) ; $ git -> getConfig ( ) -> getLogger ( ) -> debug ( \ sprintf ( '[ccabs-repository-git] exec [%s] %s' , $ process -> getWorkingDirectory ( ) , $ process -> getCommandLine ( ) ) ) ; $ process -> run ( ) ; $ output = \ rtrim ( $ process -> getOutput ( ) , "\r\n" ) ; if ( ! $ process -> isSuccessful ( ) ) { throw GitException :: createFromProcess ( 'Could not execute git command' , $ process ) ; } $ files = [ ] ; foreach ( \ explode ( PHP_EOL , $ output ) as $ file ) { $ absolutePath = $ gitDir . '/' . $ file ; if ( ! $ this -> config -> isPathExcluded ( $ absolutePath ) ) { $ files [ \ trim ( $ absolutePath ) ] = \ trim ( $ absolutePath ) ; } } return $ files ; } | Retrieve a list of all files within a git repository . |
26,019 | public function getFilePaths ( ) { $ files = [ ] ; foreach ( $ this -> config -> getIncludedPaths ( ) as $ path ) { $ files [ ] = $ this -> getAllFilesFromGit ( $ this -> getGitRepositoryFor ( $ path ) ) ; } return array_merge ( ... $ files ) ; } | Retrieve the file path to use in reporting . |
26,020 | private function determineGitRoot ( $ path ) { while ( \ strlen ( $ path ) > 1 ) { if ( \ is_dir ( $ path . DIRECTORY_SEPARATOR . '.git' ) ) { return $ path ; } $ path = \ dirname ( $ path ) ; } throw new \ RuntimeException ( 'Could not determine git root, starting from ' . \ func_get_arg ( 0 ) ) ; } | Determine the git root starting from arbitrary directory . |
26,021 | protected function getCurrentUserInfo ( $ git ) { $ arguments = [ $ git -> getConfig ( ) -> getGitExecutablePath ( ) , 'config' , '--get-regexp' , 'user.[name|email]' ] ; $ process = new Process ( $ this -> prepareProcessArguments ( $ arguments ) , $ git -> getRepositoryPath ( ) ) ; $ git -> getConfig ( ) -> getLogger ( ) -> debug ( \ sprintf ( '[git-php] exec [%s] %s' , $ process -> getWorkingDirectory ( ) , $ process -> getCommandLine ( ) ) ) ; $ process -> run ( ) ; $ output = \ rtrim ( $ process -> getOutput ( ) , "\r\n" ) ; if ( ! $ process -> isSuccessful ( ) ) { throw GitException :: createFromProcess ( 'Could not execute git command' , $ process ) ; } $ config = array ( ) ; foreach ( \ explode ( PHP_EOL , $ output ) as $ line ) { list ( $ name , $ value ) = \ explode ( ' ' , $ line , 2 ) ; $ config [ \ trim ( $ name ) ] = \ trim ( $ value ) ; } if ( isset ( $ config [ 'user.name' ] ) && $ config [ 'user.email' ] ) { return \ sprintf ( '%s <%s>' , $ config [ 'user.name' ] , $ config [ 'user.email' ] ) ; } return '' ; } | Retrieve the data of the current user on the system . |
26,022 | private function runCustomGit ( array $ arguments , GitRepository $ git ) { $ process = new Process ( $ this -> prepareProcessArguments ( $ arguments ) , $ git -> getRepositoryPath ( ) ) ; $ git -> getConfig ( ) -> getLogger ( ) -> debug ( \ sprintf ( '[git-php] exec [%s] %s' , $ process -> getWorkingDirectory ( ) , $ process -> getCommandLine ( ) ) ) ; $ process -> run ( ) ; $ result = rtrim ( $ process -> getOutput ( ) , "\r\n" ) ; if ( ! $ process -> isSuccessful ( ) ) { throw GitException :: createFromProcess ( 'Could not execute git command' , $ process ) ; } return $ result ; } | Run a custom git process . |
26,023 | protected function prepareProcessArguments ( array $ arguments ) { $ reflection = new \ ReflectionClass ( ProcessUtils :: class ) ; if ( ! $ reflection -> hasMethod ( 'escapeArgument' ) ) { return $ arguments ; } return \ implode ( ' ' , \ array_map ( [ ProcessUtils :: class , 'escapeArgument' ] , $ arguments ) ) ; } | Prepare the command line arguments for the symfony process . |
26,024 | public static function load ( string $ filename = 'my-addresses.php' ) : array { $ file = ( new static ( ) ) -> getDirectoryPaths ( ) -> map ( function ( $ path ) use ( $ filename ) { return $ path . $ filename ; } ) -> first ( function ( $ file ) { return file_exists ( $ file ) ; } ) ; if ( ! $ file ) { throw new PartialNotFoundException ( vsprintf ( '%s does not exist.' , [ $ filename , ] ) ) ; } return include $ file ; } | Load addresses from a file . |
26,025 | public function setReplyMarkup ( \ KeythKatz \ TelegramBotCore \ Type \ InlineKeyboardMarkup $ keyboard ) : void { $ this -> baseMethod -> setReplyMarkup ( $ keyboard ) ; } | Set the inline keyboard for the message . |
26,026 | public function send ( ) : void { $ sentMessage = $ this -> baseMethod -> send ( ) ; $ this -> messageId = $ sentMessage -> getMessageId ( ) ; $ this -> chatId = $ sentMessage -> getChat ( ) -> getId ( ) ; $ this -> saveState ( ) ; } | Send the message . The InteractiveMessage and its data will then be saved locally . |
26,027 | public function render ( ) { $ data = $ this -> createData ( ) ; $ table = $ this -> createTable ( $ data , $ this -> options [ self :: LISTVIEW_PARAM_TABLE_CLASS ] ) ; return $ table -> render ( ) ; } | Renders the list grid |
26,028 | private function createData ( ) { $ output = array ( ) ; $ hasTranslator = $ this -> translator instanceof TranslatorInterface ; foreach ( $ this -> options [ self :: LISTVIEW_PARAM_COLUMNS ] as $ configuration ) { if ( isset ( $ this -> data [ $ configuration [ self :: LISTVIEW_PARAM_COLUMN ] ] ) ) { if ( isset ( $ configuration [ self :: LISTVIEW_PARAM_VALUE ] ) && is_callable ( $ configuration [ self :: LISTVIEW_PARAM_VALUE ] ) ) { $ value = $ configuration [ self :: LISTVIEW_PARAM_VALUE ] ( $ configuration [ self :: LISTVIEW_PARAM_COLUMN ] , $ this -> data [ $ configuration [ self :: LISTVIEW_PARAM_COLUMN ] ] ) ; } else { $ value = $ this -> data [ $ configuration [ self :: LISTVIEW_PARAM_COLUMN ] ] ; } if ( isset ( $ configuration [ self :: LISTVIEW_PARAM_TRANSLATE ] ) && $ configuration [ self :: LISTVIEW_PARAM_TRANSLATE ] == true ) { $ value = $ this -> translator -> translate ( $ value ) ; } if ( isset ( $ configuration [ self :: LISTVIEW_PARAM_TITLE ] ) ) { $ key = $ configuration [ self :: LISTVIEW_PARAM_TITLE ] ; } else { $ key = TextUtils :: normalizeColumn ( $ configuration [ self :: LISTVIEW_PARAM_COLUMN ] ) ; } $ key = $ hasTranslator ? $ this -> translator -> translate ( $ key ) : $ key ; $ output [ $ key ] = $ value ; } } return $ output ; } | Prepares data by reading from configuration |
26,029 | private function createRow ( $ key , $ value ) { $ tr = new NodeElement ( ) ; $ tr -> openTag ( 'tr' ) ; $ first = new NodeElement ( ) ; $ first -> openTag ( 'td' ) -> finalize ( ) -> setText ( $ key ) -> closeTag ( ) ; $ second = new NodeElement ( ) ; $ second -> openTag ( 'td' ) -> finalize ( ) -> setText ( $ value ) -> closeTag ( ) ; $ tr -> appendChildren ( array ( $ first , $ second ) ) ; $ tr -> closeTag ( ) ; return $ tr ; } | Creates table row |
26,030 | private function build ( ) : void { $ prefix = "<?xml version='1.0' encoding='UTF-8'?>" . $ this -> glue ( ) . "<feed xmlns='http://www.w3.org/2005/Atom' xmlns:apps='http://schemas.google.com/apps/2006'>" ; $ suffix = '</feed>' ; $ xml = collect ( $ this -> filters ) -> map ( function ( $ items ) { return $ this -> buildEntry ( $ items ) ; } ) -> implode ( $ this -> glue ( ) ) ; $ this -> xml = collect ( [ $ prefix , $ xml , $ suffix ] ) -> implode ( $ this -> glue ( ) ) ; if ( $ this -> writeFile ) { $ this -> filesystem -> dumpFile ( $ this -> outputFile , $ this -> xml ) ; } } | Build XML for a set of filters . |
26,031 | private function buildEntry ( Filter $ filter ) : string { $ entry = collect ( $ filter -> toArray ( ) ) -> map ( function ( $ value , $ key ) : string { return $ this -> buildProperty ( $ value , $ key ) ; } ) -> implode ( $ this -> glue ( ) ) ; return collect ( [ '<entry>' , $ entry , '</entry>' ] ) -> implode ( $ this -> glue ( ) ) ; } | Build XML for an filter . |
26,032 | private function buildProperty ( $ value , $ key ) : string { if ( collect ( [ 'from' , 'to' ] ) -> contains ( $ key ) ) { $ value = $ this -> implode ( $ value ) ; } return vsprintf ( "<apps:property name='%s' value='%s'/>" , [ $ key , htmlentities ( $ this -> implode ( $ value ) ) , ] ) ; } | Build XML for a property . |
26,033 | private function implode ( $ value , $ separator = '|' ) : string { if ( is_string ( $ value ) ) { return $ value ; } if ( is_array ( $ value ) && count ( $ value ) === 1 ) { return reset ( $ value ) ; } return sprintf ( '(%s)' , collect ( $ value ) -> implode ( $ separator ) ) ; } | Implode values with the appropriate prefix suffix and separator . |
26,034 | public function clearCacheAction ( ) { $ this -> getConfigurationManager ( ) -> clearCache ( ) ; $ this -> addFlash ( 'sonata_flash_success' , 'Cache clear successfully' ) ; return new \ Symfony \ Component \ HttpFoundation \ RedirectResponse ( $ this -> admin -> generateUrl ( 'list' ) ) ; } | Limplia la cache |
26,035 | protected function encode ( $ originalString ) { $ encodedString = '' ; $ nowCodeString = '' ; $ originalLength = strlen ( $ originalString ) ; for ( $ i = 0 ; $ i < $ originalLength ; $ i ++ ) { $ encodeMode = ( $ i % 2 == 0 ) ? 1 : 2 ; switch ( $ encodeMode ) { case 1 : $ nowCodeString = '&#' . ord ( $ originalString [ $ i ] ) . ';' ; break ; case 2 : $ nowCodeString = '&#x' . dechex ( ord ( $ originalString [ $ i ] ) ) . ';' ; break ; default : return 'ERROR: wrong encoding mode.' ; } $ encodedString .= $ nowCodeString ; } return $ encodedString ; } | Obscure email address . |
26,036 | public function build ( array $ data ) { $ relations = array ( self :: TREE_PARAM_ITEMS => array ( ) , self :: TREE_PARAM_PARENTS => array ( ) ) ; foreach ( $ data as $ row ) { $ relations [ self :: TREE_PARAM_ITEMS ] [ $ row [ self :: TREE_PARAM_ID ] ] = $ row ; $ relations [ self :: TREE_PARAM_PARENTS ] [ $ row [ self :: TREE_PARAM_PARENT_ID ] ] [ ] = $ row [ self :: TREE_PARAM_ID ] ; } return $ relations ; } | Builds a relational tree |
26,037 | final protected function faker ( string $ locale = 'en_US' ) : Generator { static $ fakers = [ ] ; if ( ! \ array_key_exists ( $ locale , $ fakers ) ) { $ faker = Factory :: create ( $ locale ) ; $ faker -> seed ( 9001 ) ; $ fakers [ $ locale ] = $ faker ; } return $ fakers [ $ locale ] ; } | Returns a localized instance of Faker \ Generator . |
26,038 | final protected function assertClassesAreAbstractOrFinal ( string $ directory , array $ excludeClassNames = [ ] ) : void { $ this -> assertClassyConstructsSatisfySpecification ( static function ( string $ className ) : bool { $ reflection = new \ ReflectionClass ( $ className ) ; return $ reflection -> isAbstract ( ) || $ reflection -> isFinal ( ) || $ reflection -> isInterface ( ) || $ reflection -> isTrait ( ) ; } , $ directory , $ excludeClassNames , "Failed asserting that the classes\n\n%s\n\nare abstract or final." ) ; } | Asserts that classes in a directory are either abstract or final . |
26,039 | final protected function assertClassyConstructsSatisfySpecification ( callable $ specification , string $ directory , array $ excludeClassyNames = [ ] , string $ message = '' ) : void { if ( ! \ is_dir ( $ directory ) ) { throw Exception \ NonExistentDirectory :: fromDirectory ( $ directory ) ; } \ array_walk ( $ excludeClassyNames , static function ( $ excludeClassyName ) : void { if ( ! \ is_string ( $ excludeClassyName ) ) { throw Exception \ InvalidExcludeClassName :: fromClassName ( $ excludeClassyName ) ; } if ( ! \ class_exists ( $ excludeClassyName ) ) { throw Exception \ NonExistentExcludeClass :: fromClassName ( $ excludeClassyName ) ; } } ) ; $ constructs = Classy \ Constructs :: fromDirectory ( $ directory ) ; $ classyNames = \ array_diff ( $ constructs , $ excludeClassyNames ) ; $ classyNamesNotSatisfyingSpecification = \ array_filter ( $ classyNames , static function ( string $ className ) use ( $ specification ) { return false === $ specification ( $ className ) ; } ) ; self :: assertEmpty ( $ classyNamesNotSatisfyingSpecification , \ sprintf ( '' !== $ message ? $ message : "Failed asserting that the classy constructs\n\n%s\n\nsatisfy a specification." , ' - ' . \ implode ( "\n - " , $ classyNamesNotSatisfyingSpecification ) ) ) ; } | Asserts that all classes interfaces and traits found in a directory satisfy a specification . |
26,040 | final protected function assertClassExists ( string $ className ) : void { self :: assertTrue ( \ class_exists ( $ className ) , \ sprintf ( 'Failed asserting that a class "%s" exists.' , $ className ) ) ; } | Asserts that a class exists . |
26,041 | final protected function assertClassExtends ( string $ parentClassName , string $ className ) : void { $ this -> assertClassExists ( $ parentClassName ) ; $ this -> assertClassExists ( $ className ) ; $ reflection = new \ ReflectionClass ( $ className ) ; self :: assertTrue ( $ reflection -> isSubclassOf ( $ parentClassName ) , \ sprintf ( 'Failed asserting that class "%s" extends "%s".' , $ className , $ parentClassName ) ) ; } | Asserts that a class extends from a parent class . |
26,042 | final protected function assertClassImplementsInterface ( string $ interfaceName , string $ className ) : void { $ this -> assertInterfaceExists ( $ interfaceName ) ; $ this -> assertClassExists ( $ className ) ; $ reflection = new \ ReflectionClass ( $ className ) ; self :: assertTrue ( $ reflection -> implementsInterface ( $ interfaceName ) , \ sprintf ( 'Failed asserting that class "%s" implements interface "%s".' , $ className , $ interfaceName ) ) ; } | Asserts that a class implements an interface . |
26,043 | final protected function assertClassIsAbstract ( string $ className ) : void { $ this -> assertClassExists ( $ className ) ; $ reflection = new \ ReflectionClass ( $ className ) ; self :: assertTrue ( $ reflection -> isAbstract ( ) , \ sprintf ( 'Failed asserting that class "%s" is abstract.' , $ className ) ) ; } | Asserts that a class is abstract . |
26,044 | final protected function assertClassIsFinal ( string $ className ) : void { $ this -> assertClassExists ( $ className ) ; $ reflection = new \ ReflectionClass ( $ className ) ; self :: assertTrue ( $ reflection -> isFinal ( ) , \ sprintf ( 'Failed asserting that class "%s" is final.' , $ className ) ) ; } | Asserts that a class is final . |
26,045 | final protected function assertClassSatisfiesSpecification ( callable $ specification , string $ className , string $ message = '' ) : void { $ this -> assertClassExists ( $ className ) ; self :: assertTrue ( $ specification ( $ className ) , \ sprintf ( '' !== $ message ? $ message : 'Failed asserting that class "%s" satisfies a specification.' , $ className ) ) ; } | Asserts that a class satisfies a specification . |
26,046 | final protected function assertClassUsesTrait ( string $ traitName , string $ className ) : void { $ this -> assertTraitExists ( $ traitName ) ; $ this -> assertClassExists ( $ className ) ; self :: assertContains ( $ traitName , \ class_uses ( $ className ) , \ sprintf ( 'Failed asserting that class "%s" uses trait "%s".' , $ className , $ traitName ) ) ; } | Asserts that a class uses a trait . |
26,047 | final protected function assertInterfaceExists ( string $ interfaceName ) : void { self :: assertTrue ( \ interface_exists ( $ interfaceName ) , \ sprintf ( 'Failed asserting that an interface "%s" exists.' , $ interfaceName ) ) ; } | Asserts that an interface exists . |
26,048 | final protected function assertInterfaceExtends ( string $ parentInterfaceName , string $ interfaceName ) : void { $ this -> assertInterfaceExists ( $ parentInterfaceName ) ; $ this -> assertInterfaceExists ( $ interfaceName ) ; $ reflection = new \ ReflectionClass ( $ interfaceName ) ; self :: assertTrue ( $ reflection -> isSubclassOf ( $ parentInterfaceName ) , \ sprintf ( 'Failed asserting that interface "%s" extends "%s".' , $ interfaceName , $ parentInterfaceName ) ) ; } | Asserts that an interface extends a parent interface . |
26,049 | final protected function assertInterfaceSatisfiesSpecification ( callable $ specification , string $ interfaceName , string $ message = '' ) : void { $ this -> assertInterfaceExists ( $ interfaceName ) ; self :: assertTrue ( $ specification ( $ interfaceName ) , \ sprintf ( '' !== $ message ? $ message : 'Failed asserting that interface "%s" satisfies a specification.' , $ interfaceName ) ) ; } | Asserts that an interface satisfies a specification . |
26,050 | final protected function assertTraitExists ( string $ traitName ) : void { self :: assertTrue ( \ trait_exists ( $ traitName ) , \ sprintf ( 'Failed asserting that a trait "%s" exists.' , $ traitName ) ) ; } | Asserts that a trait exists . |
26,051 | final protected function assertTraitSatisfiesSpecification ( callable $ specification , string $ traitName , string $ message = '' ) : void { $ this -> assertTraitExists ( $ traitName ) ; self :: assertTrue ( $ specification ( $ traitName ) , \ sprintf ( '' !== $ message ? $ message : 'Failed asserting that trait "%s" satisfies a specification.' , $ traitName ) ) ; } | Asserts that a trait satisfies a specification . |
26,052 | public static function get ( Bookboon $ bookboon , string $ categoryId , array $ bookTypes = [ 'pdf' ] ) : BookboonResponse { $ bResponse = $ bookboon -> rawRequest ( "/categories/$categoryId" , [ 'bookType' => join ( ',' , $ bookTypes ) ] ) ; $ bResponse -> setEntityStore ( new EntityStore ( [ new static ( $ bResponse -> getReturnArray ( ) ) ] ) ) ; return $ bResponse ; } | Get Category . |
26,053 | public static function getTree ( Bookboon $ bookboon , array $ blacklistedCategoryIds = [ ] , int $ depth = 2 ) : BookboonResponse { $ bResponse = $ bookboon -> rawRequest ( '/categories' , [ 'depth' => $ depth ] ) ; $ categories = $ bResponse -> getReturnArray ( ) ; if ( count ( $ blacklistedCategoryIds ) !== 0 ) { self :: recursiveBlacklist ( $ categories , $ blacklistedCategoryIds ) ; } $ bResponse -> setEntityStore ( new EntityStore ( Category :: getEntitiesFromArray ( $ categories ) ) ) ; return $ bResponse ; } | Returns the entire Category structure . |
26,054 | public function set ( string $ header , string $ value ) : void { $ this -> headers [ $ header ] = $ value ; } | Set or override header . |
26,055 | public function getAll ( ) : array { $ headers = [ ] ; foreach ( $ this -> headers as $ h => $ v ) { $ headers [ ] = $ h . ': ' . $ v ; } return $ headers ; } | Get all headers in CURL format . |
26,056 | private function getRemoteAddress ( ) : ? string { $ hostname = null ; if ( isset ( $ _SERVER [ 'REMOTE_ADDR' ] ) ) { $ hostname = filter_var ( $ _SERVER [ 'REMOTE_ADDR' ] , FILTER_VALIDATE_IP ) ; if ( false === $ hostname ) { $ hostname = null ; } } if ( function_exists ( 'apache_request_headers' ) ) { $ headers = apache_request_headers ( ) ; if ( $ headers === false ) { return $ hostname ; } foreach ( $ headers as $ k => $ v ) { if ( strcasecmp ( $ k , 'x-forwarded-for' ) ) { continue ; } $ hostname = explode ( ',' , $ v ) ; $ hostname = trim ( $ hostname [ 0 ] ) ; break ; } } return $ hostname ; } | Returns the remote address either directly or if set XFF header value . |
26,057 | public function loadHistory ( ) { $ key = $ this -> options [ 'session_key' ] ; if ( isset ( $ _SESSION [ 'CDatabase' ] ) ) { self :: $ numQueries = $ _SESSION [ $ key ] [ 'numQueries' ] ; self :: $ queries = $ _SESSION [ $ key ] [ 'queries' ] ; self :: $ params = $ _SESSION [ $ key ] [ 'params' ] ; unset ( $ _SESSION [ $ key ] ) ; } } | Load query - history from session if available . |
26,058 | public function saveHistory ( $ extra = null ) { if ( ! is_null ( $ extra ) ) { self :: $ queries [ ] = $ extra ; self :: $ params [ ] = null ; } self :: $ queries [ ] = 'Saved query-history to session.' ; self :: $ params [ ] = null ; $ key = $ this -> options [ 'session_key' ] ; $ _SESSION [ $ key ] [ 'numQueries' ] = self :: $ numQueries ; $ _SESSION [ $ key ] [ 'queries' ] = self :: $ queries ; $ _SESSION [ $ key ] [ 'params' ] = self :: $ params ; } | Save query - history in session useful as a flashmemory when redirecting to another page . |
26,059 | public function executeFetchAll ( $ query = null , $ params = [ ] ) { $ this -> execute ( $ query , $ params ) ; return $ this -> fetchAll ( ) ; } | Execute a select - query with arguments and return all resultset . |
26,060 | public function executeFetchOne ( $ query = null , $ params = [ ] ) { $ this -> execute ( $ query , $ params ) ; return $ this -> fetchOne ( ) ; } | Execute a select - query with arguments and return one resultset . |
26,061 | public function fetchInto ( $ object ) { $ this -> stmt -> setFetchMode ( \ PDO :: FETCH_INTO , $ object ) ; return $ this -> stmt -> fetch ( ) ; } | Fetch one resultset from previous select statement as an object . |
26,062 | public static function machineName ( $ string , $ pattern = '/[^a-zA-Z0-9\-]/' ) { if ( ! is_string ( $ string ) ) { throw new \ InvalidArgumentException ( 'A non string argument has been given.' ) ; } $ string = strtr ( $ string , ' ' , '-' ) ; return strtolower ( self :: cleanString ( $ string , $ pattern ) ) ; } | Machine name from string . |
26,063 | public function hasDuplicates ( $ target ) { if ( $ this -> exists ( $ target ) ) { $ duplicates = $ this -> getDuplicates ( ) ; return ( int ) $ duplicates [ $ target ] > 1 ; } else { throw new RuntimeException ( sprintf ( 'Attempted to read non-existing value %s' , $ target ) ) ; } } | Checks if a value has duplicates in a sequence |
26,064 | public function append ( $ value ) { if ( strpos ( $ value , self :: SEPARATOR ) !== false ) { throw new LogicException ( 'A value cannot contain delimiter' ) ; } array_push ( $ this -> collection , $ value ) ; return $ this ; } | Appends one more value |
26,065 | public function exists ( ) { foreach ( func_get_args ( ) as $ value ) { if ( ! in_array ( $ value , $ this -> collection ) ) { return false ; } } return true ; } | Checks whether value exists in a stack |
26,066 | public function delete ( $ target , $ keepDuplicates = true ) { $ array = $ this -> collection ; foreach ( $ array as $ index => $ value ) { if ( $ value == $ target ) { unset ( $ array [ $ index ] ) ; if ( $ keepDuplicates === true ) { break ; } } } $ this -> collection = $ array ; } | Deletes a value from the stack |
26,067 | public function loadFromString ( $ string ) { $ target = array ( ) ; $ array = explode ( self :: SEPARATOR , $ string ) ; foreach ( $ array as $ index => $ value ) { if ( ! empty ( $ value ) ) { if ( strpos ( self :: SEPARATOR , $ value ) === false ) { array_push ( $ target , $ value ) ; } } } $ this -> collection = $ target ; } | Builds an array from a string |
26,068 | final protected function createSourceElements ( array $ sources ) { $ output = array ( ) ; foreach ( $ sources as $ type => $ src ) { $ output [ ] = $ this -> createSourceElement ( $ type , $ src ) ; } return $ output ; } | Create source node elements |
26,069 | final protected function createSourceElement ( $ type , $ src ) { $ attrs = array ( 'src' => $ src , 'type' => $ type ) ; $ node = new NodeElement ( ) ; return $ node -> openTag ( 'source' ) -> addAttributes ( $ attrs ) -> finalize ( true ) ; } | Create inner source node element |
26,070 | public function getViews ( ) { $ config = $ this -> config ; $ directories = array ( ) ; $ dir = $ this -> directory ; if ( isset ( $ config [ 'app' ] [ 'views' ] ) ) { $ directoriesTmp = $ config [ 'app' ] [ 'views' ] ; if ( ! is_array ( $ directoriesTmp ) ) { $ directoriesTmp = array ( $ directoriesTmp ) ; } foreach ( $ directoriesTmp as $ directory ) { $ this -> addFolder ( $ directories , $ dir . '/' . $ directory ) ; } } return $ directories ; } | Return folder to find views |
26,071 | public function addIgnoredProperty ( string $ type , $ propertyNames ) : void { if ( ! is_string ( $ propertyNames ) && ! is_array ( $ propertyNames ) ) { throw new InvalidArgumentException ( 'Property name must be a string or array of strings' ) ; } if ( ! isset ( $ this -> ignoredEncodedPropertyNamesByType [ $ type ] ) ) { $ this -> ignoredEncodedPropertyNamesByType [ $ type ] = [ ] ; } foreach ( ( array ) $ propertyNames as $ propertyName ) { $ this -> ignoredEncodedPropertyNamesByType [ $ type ] [ $ this -> normalizePropertyName ( $ propertyName ) ] = true ; } } | Adds a property to ignore during encoding |
26,072 | protected function decodeArrayOrVariadicConstructorParamValue ( ReflectionParameter $ constructorParam , $ constructorParamValue , EncodingContext $ context ) { if ( ! is_array ( $ constructorParamValue ) ) { throw new EncodingException ( 'Value must be an array' ) ; } if ( count ( $ constructorParamValue ) === 0 ) { return [ ] ; } if ( $ constructorParam -> isVariadic ( ) && $ constructorParam -> hasType ( ) ) { $ type = $ constructorParam -> getType ( ) . '[]' ; return $ this -> encoders -> getEncoderForType ( $ type ) -> decode ( $ constructorParamValue , $ type , $ context ) ; } if ( is_object ( $ constructorParamValue [ 0 ] ) ) { $ type = get_class ( $ constructorParamValue [ 0 ] ) . '[]' ; return $ this -> encoders -> getEncoderForType ( $ type ) -> decode ( $ constructorParamValue , $ type , $ context ) ; } $ type = gettype ( $ constructorParamValue [ 0 ] ) . '[]' ; return $ this -> encoders -> getEncoderForType ( $ type ) -> decode ( $ constructorParamValue , $ type , $ context ) ; } | Decodes a variadic constructor parameter value |
26,073 | private function decodeConstructorParamValue ( ReflectionParameter $ constructorParam , $ constructorParamValue , ReflectionClass $ reflectionClass , string $ normalizedHashPropertyName , EncodingContext $ context ) { if ( $ constructorParam -> hasType ( ) && ! $ constructorParam -> isArray ( ) && ! $ constructorParam -> isVariadic ( ) ) { $ constructorParamType = ( string ) $ constructorParam -> getType ( ) ; return $ this -> encoders -> getEncoderForType ( $ constructorParamType ) -> decode ( $ constructorParamValue , $ constructorParamType , $ context ) ; } if ( $ constructorParam -> isVariadic ( ) || $ constructorParam -> isArray ( ) ) { return $ this -> decodeArrayOrVariadicConstructorParamValue ( $ constructorParam , $ constructorParamValue , $ context ) ; } $ decodedValue = null ; if ( $ this -> tryDecodeValueFromGetterType ( $ reflectionClass , $ normalizedHashPropertyName , $ constructorParamValue , $ context , $ decodedValue ) ) { return $ decodedValue ; } if ( is_scalar ( $ constructorParamValue ) ) { $ type = gettype ( $ constructorParamValue ) ; return $ this -> encoders -> getEncoderForType ( $ type ) -> decode ( $ constructorParamValue , $ type , $ context ) ; } throw new EncodingException ( "Failed to decode constructor parameter {$constructorParam->getName()}" ) ; } | Decodes a constructor parameter value |
26,074 | private function normalizeHashProperties ( array $ objectHash ) : array { $ encodedHashProperties = [ ] ; foreach ( $ objectHash as $ propertyName => $ propertyValue ) { $ encodedHashProperties [ $ this -> normalizePropertyName ( $ propertyName ) ] = $ propertyName ; } return $ encodedHashProperties ; } | Gets the normalized hash property names to original names |
26,075 | private function propertyIsIgnored ( string $ type , string $ propertyName ) : bool { return isset ( $ this -> ignoredEncodedPropertyNamesByType [ $ type ] [ $ this -> normalizePropertyName ( $ propertyName ) ] ) ; } | Checks whether or not a property on a type is ignored |
26,076 | private function tryDecodeValueFromGetterType ( ReflectionClass $ reflectionClass , string $ normalizedPropertyName , $ encodedValue , EncodingContext $ context , & $ decodedValue ) : bool { foreach ( $ reflectionClass -> getMethods ( ReflectionMethod :: IS_PUBLIC ) as $ reflectionMethod ) { if ( ! $ reflectionMethod -> hasReturnType ( ) || $ reflectionMethod -> getReturnType ( ) === 'array' || $ reflectionMethod -> isConstructor ( ) || $ reflectionMethod -> isDestructor ( ) || $ reflectionMethod -> getNumberOfRequiredParameters ( ) > 0 ) { continue ; } $ propertyName = null ; if ( strpos ( $ reflectionMethod -> name , 'get' ) === 0 || strpos ( $ reflectionMethod -> name , 'has' ) === 0 ) { $ propertyName = lcfirst ( substr ( $ reflectionMethod -> name , 3 ) ) ; } elseif ( strpos ( $ reflectionMethod -> name , 'is' ) === 0 ) { $ propertyName = lcfirst ( substr ( $ reflectionMethod -> name , 2 ) ) ; } if ( $ propertyName === null ) { continue ; } $ encodedPropertyName = $ this -> normalizePropertyName ( $ propertyName ) ; if ( $ encodedPropertyName === $ normalizedPropertyName ) { try { $ reflectionMethodReturnType = ( string ) $ reflectionMethod -> getReturnType ( ) ; $ decodedValue = $ this -> encoders -> getEncoderForType ( $ reflectionMethodReturnType ) -> decode ( $ encodedValue , $ reflectionMethodReturnType , $ context ) ; return true ; } catch ( EncodingException $ ex ) { return false ; } } } return false ; } | Decodes a value using the type info from get is or has methods |
26,077 | public function filter ( $ value ) { return is_array ( $ value ) ? array_map ( array ( $ this , __FUNCTION__ ) , $ value ) : stripslashes ( $ value ) ; } | Recursively filter slashes in array |
26,078 | public function getLastCategoryId ( ) { $ value = $ this -> getData ( ) ; if ( $ this -> flashed === true ) { $ this -> clearData ( ) ; } return $ value ; } | Returns last category id |
26,079 | public function getDefaultPaymentConfig ( ) { $ configuration = [ ] ; $ isActive = $ this -> enhancementHelper -> isActiveDefaultPayment ( ) ; $ configuration [ 'isActiveDefaultPayment' ] = $ isActive ; if ( $ isActive ) { $ configuration [ 'defaultMethod' ] = $ this -> enhancementHelper -> getDefaultMethod ( ) ; } return $ configuration ; } | Returns default payment config |
26,080 | public function getGoogleAddressConfig ( ) { $ configuration = [ ] ; $ isActive = $ this -> enhancementHelper -> isActiveGoogleAddress ( ) ; $ configuration [ 'isActiveGoogleAddress' ] = $ isActive ; if ( $ isActive ) { $ configuration [ 'googleAddressCountry' ] = $ this -> enhancementHelper -> getGoogleMapAddressCountries ( ) ; } return $ configuration ; } | Returns Google Maps Search Address config |
26,081 | public function getPartialFile ( $ name ) { $ file = $ this -> findPartialFile ( $ name ) ; if ( is_file ( $ file ) ) { return $ file ; } else if ( $ this -> hasStaticPartial ( $ name ) ) { return $ this -> getStaticFile ( $ name ) ; } else { throw new LogicException ( sprintf ( 'Could not find a registered partial called %s' , $ name ) ) ; } } | Attempts to return partial file path |
26,082 | public function addStaticPartial ( $ baseDir , $ name ) { $ file = $ this -> createPartialPath ( $ baseDir , $ name ) ; if ( ! is_file ( $ file ) ) { throw new LogicException ( sprintf ( 'Invalid base directory or file name provided "%s"' , $ file ) ) ; } $ this -> staticPartials [ $ name ] = $ file ; return $ this ; } | Adds new static partial to collection |
26,083 | public function addStaticPartials ( array $ collection ) { foreach ( $ collection as $ baseDir => $ name ) { $ this -> addStaticPartial ( $ baseDir , $ name ) ; } return $ this ; } | Adds a collection of static partials |
26,084 | private function findPartialFile ( $ name ) { foreach ( $ this -> partialDirs as $ dir ) { $ file = $ this -> createPartialPath ( $ dir , $ name ) ; if ( is_file ( $ file ) ) { return $ file ; } } return false ; } | Tries to find a partial within registered directories |
26,085 | protected function _setRules ( ) { $ resources = $ this -> getResources ( ) ; $ rulesCollection = Mage :: getResourceModel ( 'api2/acl_global_rule_collection' ) ; foreach ( $ rulesCollection as $ rule ) { if ( Mage_Api2_Model_Acl_Global_Rule :: RESOURCE_ALL === $ rule -> getResourceId ( ) ) { if ( in_array ( $ rule -> getRoleId ( ) , Mage_Api2_Model_Acl_Global_Role :: getSystemRoles ( ) ) ) { $ role = $ this -> _getRolesCollection ( ) -> getItemById ( $ rule -> getRoleId ( ) ) ; $ privileges = $ this -> _getConfig ( ) -> getResourceUserPrivileges ( $ this -> _resourceType , $ role -> getConfigNodeName ( ) ) ; if ( ! array_key_exists ( $ this -> _operation , $ privileges ) ) { continue ; } } $ this -> allow ( $ rule -> getRoleId ( ) ) ; } elseif ( in_array ( $ rule -> getResourceId ( ) , $ resources ) ) { $ this -> allow ( $ rule -> getRoleId ( ) , $ rule -> getResourceId ( ) , $ rule -> getPrivilege ( ) ) ; } } return $ this ; } | Retrieve rules data from DB and inject it into ACL |
26,086 | public function getRequestHeader ( $ header , $ default = false ) { if ( $ this -> hasRequestHeader ( $ header ) ) { $ headers = $ this -> getAllRequestHeaders ( ) ; return $ headers [ $ header ] ; } else { return $ default ; } } | Returns request header if present |
26,087 | public function setStatusCode ( $ code ) { static $ sg = null ; if ( is_null ( $ sg ) ) { $ sg = new StatusGenerator ( ) ; } $ status = $ sg -> generate ( $ code ) ; if ( $ status !== false ) { $ this -> append ( $ status ) ; } return $ this ; } | Sets status code |
26,088 | public function setMany ( array $ headers ) { $ this -> clear ( ) ; foreach ( $ headers as $ header ) { $ this -> append ( $ header ) ; } return $ this ; } | Set many headers at once and clear all previous ones |
26,089 | public function appendPair ( $ key , $ value ) { $ header = sprintf ( '%s: %s' , $ key , $ value ) ; $ this -> append ( $ header ) ; return $ this ; } | Appends a pair |
26,090 | public function appendPairs ( array $ headers ) { foreach ( $ headers as $ key => $ value ) { $ this -> appendPair ( $ key , $ value ) ; } return $ this ; } | Append several pairs |
26,091 | public function display ( ) { \ http_response_code ( $ this -> getResponseCode ( ) ) ; if ( $ this -> contentType ) { header ( 'Content-Type: ' . $ this -> contentType ) ; } if ( $ this -> redirection ) { header ( 'Location: ' . $ this -> redirection ) ; } Events :: dispatch ( 'beforeResponseSend' , array ( $ this ) ) ; session_write_close ( ) ; print $ this -> content ; Profiler :: dump ( ) ; Events :: dispatch ( 'afterResponseSend' , array ( $ this ) ) ; } | Envia la respuesta al cliente |
26,092 | public function compress ( $ content ) { ini_set ( 'pcre.recursion_limit' , '16777' ) ; $ content = $ this -> removeSpaces ( $ content ) ; $ content = $ this -> removeComments ( $ content ) ; return $ content ; } | Compresses the string |
26,093 | protected function findDrupalDocroot ( ) { $ engine = $ this -> engineInstance ( ) ; $ project = $ this -> projectInstance ( ) ; if ( $ engine instanceof DockerEngineType && ! $ this -> localhost ) { return "/var/www/html/{$project->getInstallRoot(true)}" ; } return $ project -> getInstallPath ( ) ; } | Find Drupal docroot . |
26,094 | public function getEditForm ( $ id = null , $ fields = null ) { $ form = parent :: getEditForm ( $ id , $ fields ) ; $ siteConfig = SiteConfig :: current_site_config ( ) ; if ( $ this -> modelClass === "Tag" && $ siteConfig -> AllowTags ) { $ form -> Fields ( ) -> fieldByName ( 'Tag' ) -> getConfig ( ) -> addComponent ( new GridFieldOrderableRows ( 'SortOrder' ) ) ; } if ( $ this -> modelClass === "News" && ! $ siteConfig -> AllowExport ) { $ form -> Fields ( ) -> fieldByName ( "News" ) -> getConfig ( ) -> removeComponentsByType ( 'GridFieldExportButton' ) -> addComponent ( new GridfieldNewsPublishAction ( ) ) ; } return $ form ; } | Add the sortorder to tags . I guess tags are sortable now . |
26,095 | public function getList ( ) { $ list = parent :: getList ( ) ; if ( $ this -> modelClass === 'News' && class_exists ( 'Subsite' ) && Subsite :: currentSubsiteID ( ) > 0 ) { $ pages = NewsHolderPage :: get ( ) -> filter ( array ( 'SubsiteID' => ( int ) Subsite :: currentSubsiteID ( ) ) ) ; $ filter = $ pages -> column ( 'ID' ) ; $ list = $ list -> innerJoin ( 'NewsHolderPage_Newsitems' , 'NewsHolderPage_Newsitems.NewsID = News.ID' ) -> filter ( array ( 'NewsHolderPage_Newsitems.NewsHolderPageID' => $ filter ) ) ; } return $ list ; } | List only newsitems from current subsite . |
26,096 | private function validateDigits ( & $ digits ) { ksort ( $ digits ) ; if ( count ( $ digits ) < 2 ) { throw new \ InvalidArgumentException ( 'Number base must have at least 2 digits' ) ; } elseif ( array_keys ( $ digits ) !== range ( 0 , count ( $ digits ) - 1 ) ) { throw new \ InvalidArgumentException ( 'Invalid digit values in the number base' ) ; } elseif ( $ this -> detectDuplicates ( $ digits ) ) { throw new \ InvalidArgumentException ( 'Number base cannot have duplicate digits' ) ; } } | Validates and sorts the list of digits . |
26,097 | private function detectDuplicates ( array $ digits ) { for ( $ i = count ( $ digits ) ; $ i > 0 ; $ i -- ) { if ( array_search ( array_pop ( $ digits ) , $ digits ) !== false ) { return true ; } } return false ; } | Tells if the list of digits has duplicate values . |
26,098 | private function detectConflict ( array $ digits , callable $ detect ) { foreach ( $ digits as $ digit ) { if ( $ this -> inDigits ( $ digit , $ digits , $ detect ) ) { return true ; } } return false ; } | Tells if a conflict exists between string values . |
26,099 | private function inDigits ( $ digit , array $ digits , callable $ detect ) { foreach ( $ digits as $ haystack ) { if ( $ digit !== $ haystack && $ detect ( $ haystack , $ digit ) !== false ) { return true ; } } return false ; } | Tells if a conflict exists for a digit in a list of digits . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.