idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
35,900
public function created ( Events \ Created $ event ) : bool { if ( config ( 'tenancy.website.auto-create-tenant-directory' ) ) { $ stat = $ this -> filesystem ( ) -> makeDirectory ( $ event -> website -> uuid ) ; if ( $ stat ) { $ this -> emitEvent ( new DirectoryCreated ( $ event -> website , $ this -> filesystem ( ) ...
Mutates the service based on a website being enabled .
35,901
public function deleted ( Events \ Deleted $ event ) : bool { if ( config ( 'tenancy.website.auto-delete-tenant-directory' ) ) { $ stat = $ this -> filesystem ( ) -> deleteDirectory ( $ event -> website -> uuid ) ; if ( $ stat ) { $ this -> emitEvent ( new DirectoryDeleted ( $ event -> website , $ this -> filesystem ( ...
Acts on this service whenever a website is disabled .
35,902
public function hostname ( Hostname $ hostname = null ) : ? Hostname { if ( $ hostname !== null ) { $ this -> app -> instance ( CurrentHostname :: class , $ hostname ) ; $ this -> emitEvent ( new Events \ Hostnames \ Switched ( $ hostname ) ) ; return $ hostname ; } return $ this -> app -> make ( CurrentHostname :: cla...
Get or set the current hostname .
35,903
public function tenant ( Website $ website = null ) : ? Website { if ( $ website !== null ) { $ this -> app -> instance ( Tenant :: class , $ website ) ; $ this -> emitEvent ( new Events \ Websites \ Switched ( $ website ) ) ; return $ website ; } return $ this -> app -> make ( Tenant :: class ) ; }
Get or set current tenant .
35,904
public function proxy ( WebsiteEvent $ event ) { if ( $ event -> website ) { $ this -> directory ( $ event -> website ) ; } elseif ( $ this -> requiresWebsite ) { return ; } if ( $ this -> requiresPath && ! $ this -> exists ( ) ) { return ; } $ result = $ this -> load ( $ event ) ; return $ result ; }
Proxies fired events to configure the handler .
35,905
public function exists ( string $ connection = null ) : bool { $ connection = $ connection ?? $ this -> tenantName ( ) ; return Arr :: has ( $ this -> db -> getConnections ( ) , $ connection ) ; }
Checks whether a connection has been set up .
35,906
public function system ( $ for = null ) : \ Illuminate \ Database \ Connection { $ website = $ this -> convertWebsiteOrHostnameToWebsite ( $ for ) ; return $ this -> db -> connection ( $ website && $ website -> managed_by_database_connection ? $ website -> managed_by_database_connection : $ this -> systemName ( ) ) ; }
Gets the system connection .
35,907
public function purge ( $ connection = null ) { $ connection = $ connection ?? $ this -> tenantName ( ) ; $ this -> db -> purge ( $ connection ) ; $ this -> config -> set ( sprintf ( 'database.connections.%s' , $ connection ) , [ ] ) ; }
Purges the current tenant connection .
35,908
public function copy ( $ from , $ to ) { return $ this -> filesystem -> copy ( $ this -> path ( $ from ) , $ this -> path ( $ to ) ) ; }
Copy a file to a new location .
35,909
private function generateMatchMethod ( bool $ supportsRedirections ) : string { $ matchHost = false ; $ routes = new StaticPrefixCollection ( ) ; foreach ( $ this -> getRoutes ( ) -> all ( ) as $ name => $ route ) { if ( $ host = $ route -> getHost ( ) ) { $ matchHost = true ; $ host = '/' . strtr ( strrev ( $ host ) ,...
Generates the code for the match method implementing UrlMatcherInterface .
35,910
private function compileRoutes ( RouteCollection $ routes , bool $ matchHost ) : string { [ $ staticRoutes , $ dynamicRoutes ] = $ this -> groupStaticRoutes ( $ routes ) ; $ code = $ this -> compileStaticRoutes ( $ staticRoutes , $ matchHost ) ; $ chunkLimit = \ count ( $ dynamicRoutes ) ; while ( true ) { try { $ this...
Generates PHP code to match a RouteCollection with all its routes .
35,911
private function compileSwitchDefault ( bool $ hasVars , bool $ matchHost ) : string { if ( $ hasVars ) { $ code = <<<EOF foreach (\$vars as \$i => \$v) { if (isset(\$matches[1 + \$i])) { \$ret[\$v] = \$matches[1 + \$i]; } }EOF ; } elseif ( $ match...
A simple helper to compiles the switch s default for both static and dynamic routes .
35,912
private function extractTagParts ( string $ tagLine ) : array { $ matches = [ ] ; if ( ! preg_match ( '/^@(' . self :: REGEX_TAGNAME . ')(?:\s*([^\s].*)|$)/us' , $ tagLine , $ matches ) ) { throw new \ InvalidArgumentException ( 'The tag "' . $ tagLine . '" does not seem to be wellformed, please check it for errors' ) ...
Extracts all components for a tag .
35,913
private function createTag ( string $ body , string $ name , TypeContext $ context ) : ? Tag { $ handlerClassName = $ this -> findHandlerClassName ( $ name , $ context ) ; $ arguments = $ this -> getArgumentsForParametersFromWiring ( $ this -> fetchParametersForHandlerFactoryMethod ( $ handlerClassName ) , $ this -> ge...
Creates a new tag object with the given name and body or returns null if the tag name was recognized but the body was invalid .
35,914
private function getArgumentsForParametersFromWiring ( $ parameters , $ locator ) : array { $ arguments = [ ] ; foreach ( $ parameters as $ index => $ parameter ) { $ typeHint = $ parameter -> getClass ( ) ? $ parameter -> getClass ( ) -> getName ( ) : null ; if ( isset ( $ locator [ $ typeHint ] ) ) { $ arguments [ ] ...
Retrieves the arguments that need to be passed to the Factory Method with the given Parameters .
35,915
private function fetchParametersForHandlerFactoryMethod ( string $ handlerClassName ) : array { if ( ! isset ( $ this -> tagHandlerParameterCache [ $ handlerClassName ] ) ) { $ methodReflection = new \ ReflectionMethod ( $ handlerClassName , 'create' ) ; $ this -> tagHandlerParameterCache [ $ handlerClassName ] = $ met...
Retrieves a series of ReflectionParameter objects for the static create method of the given tag handler class name .
35,916
private function getServiceLocatorWithDynamicParameters ( TypeContext $ context , string $ tagName , string $ tagBody ) : array { $ locator = array_merge ( $ this -> serviceLocator , [ 'name' => $ tagName , 'body' => $ tagBody , TypeContext :: class => $ context , ] ) ; return $ locator ; }
Returns a copy of this class Service Locator with added dynamic parameters such as the tag s name body and Context .
35,917
public function Connect ( $ Address , $ Port , $ Timeout = 3 , $ Engine = self :: SOURCE ) { $ this -> Disconnect ( ) ; if ( ! is_int ( $ Timeout ) || $ Timeout < 0 ) { throw new InvalidArgumentException ( 'Timeout must be an integer.' , InvalidArgumentException :: TIMEOUT_NOT_INTEGER ) ; } $ this -> Socket -> Open ( $...
Opens connection to server
35,918
public function Disconnect ( ) { $ this -> Connected = false ; $ this -> Challenge = 0 ; $ this -> Socket -> Close ( ) ; if ( $ this -> Rcon ) { $ this -> Rcon -> Close ( ) ; $ this -> Rcon = null ; } }
Closes all open connections
35,919
public function GetPlayers ( ) { if ( ! $ this -> Connected ) { throw new SocketException ( 'Not connected.' , SocketException :: NOT_CONNECTED ) ; } $ this -> GetChallenge ( self :: A2S_PLAYER , self :: S2A_PLAYER ) ; $ this -> Socket -> Write ( self :: A2S_PLAYER , $ this -> Challenge ) ; $ Buffer = $ this -> Socket ...
Get players on the server
35,920
public function Rcon ( $ Command ) { if ( ! $ this -> Connected ) { throw new SocketException ( 'Not connected.' , SocketException :: NOT_CONNECTED ) ; } if ( $ this -> Rcon === null ) { throw new SocketException ( 'You must set a RCON password before trying to execute a RCON command.' , SocketException :: NOT_CONNECTE...
Sends a command to the server for execution .
35,921
public function Get ( $ Length = - 1 ) { if ( $ Length === 0 ) { return '' ; } $ Remaining = $ this -> Remaining ( ) ; if ( $ Length === - 1 ) { $ Length = $ Remaining ; } else if ( $ Length > $ Remaining ) { return '' ; } $ Data = SubStr ( $ this -> Buffer , $ this -> Position , $ Length ) ; $ this -> Position += $ Le...
Gets data from buffer
35,922
public function GetShort ( ) { if ( $ this -> Remaining ( ) < 2 ) { throw new InvalidPacketException ( 'Not enough data to unpack a short.' , InvalidPacketException :: BUFFER_EMPTY ) ; } $ Data = UnPack ( 'v' , $ this -> Get ( 2 ) ) ; return $ Data [ 1 ] ; }
Get short from buffer
35,923
public function GetLong ( ) { if ( $ this -> Remaining ( ) < 4 ) { throw new InvalidPacketException ( 'Not enough data to unpack a long.' , InvalidPacketException :: BUFFER_EMPTY ) ; } $ Data = UnPack ( 'l' , $ this -> Get ( 4 ) ) ; return $ Data [ 1 ] ; }
Get long from buffer
35,924
public function GetFloat ( ) { if ( $ this -> Remaining ( ) < 4 ) { throw new InvalidPacketException ( 'Not enough data to unpack a float.' , InvalidPacketException :: BUFFER_EMPTY ) ; } $ Data = UnPack ( 'f' , $ this -> Get ( 4 ) ) ; return $ Data [ 1 ] ; }
Get float from buffer
35,925
public function GetUnsignedLong ( ) { if ( $ this -> Remaining ( ) < 4 ) { throw new InvalidPacketException ( 'Not enough data to unpack an usigned long.' , InvalidPacketException :: BUFFER_EMPTY ) ; } $ Data = UnPack ( 'V' , $ this -> Get ( 4 ) ) ; return $ Data [ 1 ] ; }
Get unsigned long from buffer
35,926
public function GetString ( ) { $ ZeroBytePosition = StrPos ( $ this -> Buffer , "\0" , $ this -> Position ) ; if ( $ ZeroBytePosition === false ) { return '' ; } $ String = $ this -> Get ( $ ZeroBytePosition - $ this -> Position ) ; $ this -> Position ++ ; return $ String ; }
Read one string from buffer ending with null byte
35,927
public function Read ( $ Length = 1400 ) { $ Buffer = new Buffer ( ) ; $ Buffer -> Set ( FRead ( $ this -> Socket , $ Length ) ) ; $ this -> ReadInternal ( $ Buffer , $ Length , [ $ this , 'Sherlock' ] ) ; return $ Buffer ; }
Reads from socket and returns Buffer .
35,928
protected function getAllModules ( ) { return $ this -> extensionManager -> discoverModules ( ) -> showInstalled ( ) -> showUninstalled ( ) -> showNoCore ( ) -> showCore ( ) -> getList ( true ) ; }
Get module of all modules in the system .
35,929
protected function findHooksInApiFile ( $ moduleInstance ) { $ finder = new Finder ( ) ; $ files = $ finder -> files ( ) -> name ( "{$moduleInstance->info['name']}.api.php" ) -> in ( $ moduleInstance -> getPath ( ) ) ; foreach ( $ files as $ file ) { $ functions = $ this -> getFileFunctions ( $ file -> getPathname ( ) ...
Gets gooks from api file of the module .
35,930
protected function getFileFunctions ( $ filePath ) { $ source = file_get_contents ( $ filePath ) ; $ tokens = token_get_all ( $ source ) ; $ functions = [ ] ; $ nextStringIsFunc = false ; foreach ( $ tokens as $ token ) { switch ( $ token [ 0 ] ) { case T_FUNCTION : $ nextStringIsFunc = true ; break ; case T_STRING : i...
Get names of all functions from file .
35,931
public function moduleQuestion ( $ showProfile = true ) { $ modules = $ this -> extensionManager -> discoverModules ( ) -> showInstalled ( ) -> showUninstalled ( ) -> showNoCore ( ) -> getList ( true ) ; if ( $ showProfile ) { $ profiles = $ this -> extensionManager -> discoverProfiles ( ) -> showInstalled ( ) -> showU...
Ask the user to choose a module or profile .
35,932
public function getModuleOption ( ) { $ input = $ this -> getIo ( ) -> getInput ( ) ; $ module = $ input -> getOption ( 'module' ) ; if ( ! $ module ) { $ module = $ this -> moduleQuestion ( ) ; $ input -> setOption ( 'module' , $ module ) ; } else { $ this -> validateModule ( $ module ) ; } return $ module ; }
Get module name from user .
35,933
public function validateModule ( $ module ) { $ missing_modules = $ this -> validator -> getMissingModules ( [ $ module ] ) ; if ( $ missing_modules ) { throw new \ Exception ( sprintf ( $ this -> trans ( 'commands.module.download.messages.no-releases' ) , $ module ) ) ; } return $ module ; }
Validate module .
35,934
protected function getAutocompleteList ( $ status = 1 ) { $ theme_list = [ ] ; foreach ( $ this -> getThemes ( ) as $ theme_id => $ theme ) { if ( ! empty ( $ theme -> info [ 'hidden' ] ) ) { continue ; } if ( ! empty ( $ theme -> status == $ status ) ) { continue ; } $ theme_list [ $ theme_id ] = $ theme -> getName ( ...
Gets list of themes for autocomplete based on status .
35,935
protected function setMessage ( $ type , $ translationString , $ value ) { $ text = is_array ( $ value ) ? implode ( ',' , $ value ) : $ value ; $ this -> getIo ( ) -> { $ type } ( sprintf ( $ this -> trans ( $ translationString ) , $ text ) ) ; }
Sets message in Drupal Console .
35,936
private function getInterface ( $ class ) { $ interfaceName = $ class ; $ interfaces = class_implements ( $ class ) ; if ( ! empty ( $ interfaces ) ) { if ( count ( $ interfaces ) == 1 ) { $ interfaceName = array_shift ( $ interfaces ) ; } elseif ( $ key = array_search ( $ class . 'Interface' , $ interfaces ) ) { $ int...
Gets class interface .
35,937
public function getCaches ( ) { if ( ! $ this -> caches ) { foreach ( Cache :: getBins ( ) as $ name => $ bin ) { $ this -> caches [ $ name ] = $ bin ; } } return $ this -> caches ; }
Auxiliary function to get all available drupal caches .
35,938
public function isValidCache ( $ cache ) { $ caches = $ this -> getCaches ( ) ; $ cacheKeys = array_keys ( $ caches ) ; $ cacheKeys [ ] = 'all' ; if ( ! in_array ( $ cache , array_values ( $ cacheKeys ) ) ) { return false ; } return $ cache ; }
Validate if a string is a valid cache .
35,939
public function getPackagistModuleReleases ( $ module , $ limit = 10 , $ unstable = true ) { if ( ! trim ( $ module ) ) { return [ ] ; } return $ this -> getComposerReleases ( sprintf ( 'http://packagist.drupal-composer.org/packages/drupal/%s.json' , trim ( $ module ) ) , $ limit , $ unstable ) ; }
Gets Drupal modules releases from Packagist API .
35,940
private function getComposerReleases ( $ url , $ limit = 10 , $ unstable = false ) { if ( ! $ url ) { return [ ] ; } $ packagistResponse = $ this -> httpClient -> getUrlAsString ( $ url ) ; if ( $ packagistResponse -> getStatusCode ( ) != 200 ) { throw new \ Exception ( 'Invalid path.' ) ; } try { $ packagistJson = jso...
Gets Drupal releases from Packagist API .
35,941
private function deleteExistingTerms ( $ vid = null ) { $ termStorage = $ this -> entityTypeManager -> getStorage ( 'taxonomy_term' ) ; $ vocabularies = $ this -> getVocabularies ( ) ; if ( $ vid === 'all' ) { $ vid = array_keys ( $ vocabularies ) ; } else { $ vid = [ $ vid ] ; } foreach ( $ vid as $ item ) { $ vocabul...
Destroy all existing terms
35,942
public function getRolesAssignedByPermission ( $ permission_name ) { $ roles = user_roles ( ) ; $ roles_found = [ ] ; foreach ( $ roles as $ role ) { if ( $ role -> hasPermission ( $ permission_name ) ) { $ roles_found [ ] = $ role -> getOriginalId ( ) ; } } return $ roles_found ; }
Get user roles Assigned by Permission .
35,943
protected function getFeatureList ( $ bundle ) { $ features = [ ] ; $ manager = $ this -> getFeatureManager ( ) ; $ modules = $ this -> getPackagesByBundle ( $ bundle ) ; foreach ( $ modules as $ module_name ) { $ feature = $ manager -> loadPackage ( $ module_name , true ) ; $ overrides = $ manager -> detectOverrides (...
Get a list of features .
35,944
private function repositoryAlreadySet ( $ config , $ repo ) { if ( ! $ config -> repositories ) { return false ; } else { if ( in_array ( $ repo , $ config -> repositories ) ) { return true ; } else { return false ; } } }
check if a modules repo is in composer . json check if the repo is setted and matchs the one in config . yml
35,945
protected function addToSitesFile ( $ uri ) { if ( $ this -> fs -> exists ( $ this -> appRoot . '/sites/sites.php' ) ) { $ sites_is_dir = is_dir ( $ this -> appRoot . '/sites/sites.php' ) ; $ sites_readable = is_readable ( $ this -> appRoot . '/sites/sites.php' ) ; if ( $ sites_is_dir || ! $ sites_readable ) { throw ne...
Adds line to sites . php that is needed for the new site to be recognized .
35,946
protected function copyExistingInstall ( ) { if ( ! $ this -> fs -> exists ( $ this -> appRoot . '/sites/default/settings.php' ) ) { $ this -> getIo ( ) -> error ( sprintf ( $ this -> trans ( 'commands.multisite.new.errors.file-missing' ) , 'sites/default/settings.php' ) ) ; return 1 ; } if ( $ this -> fs -> exists ( $...
Copies detected default install alters settings . php to fit the new directory .
35,947
protected function createFreshSite ( ) { if ( $ this -> fs -> exists ( $ this -> appRoot . '/sites/default/default.settings.php' ) ) { try { $ this -> fs -> copy ( $ this -> appRoot . '/sites/default/default.settings.php' , $ this -> appRoot . '/sites/' . $ this -> directory . '/settings.php' ) ; } catch ( IOExceptionI...
Creates site folder with clean settings . php file .
35,948
protected function chmodSettings ( ) { try { $ this -> fs -> chmod ( $ this -> appRoot . '/sites/' . $ this -> directory . '/settings.php' , 0640 ) ; } catch ( IOExceptionInterface $ e ) { $ this -> getIo ( ) -> error ( sprintf ( $ this -> trans ( 'commands.multisite.new.errors.chmod-fail' ) , $ this -> appRoot . '/sit...
Changes permissions of settings . php to 640 .
35,949
protected function checkLanguages ( $ languageArguments ) { $ languages = $ this -> site -> getStandardLanguages ( ) ; $ language_codes = array_keys ( $ languages ) ; $ buildLanguages = [ ] ; foreach ( $ languageArguments as $ language ) { if ( array_search ( $ language , $ language_codes ) ) { $ buildLanguages [ $ lan...
Checks the existance of the languages in the system .
35,950
protected function getUserId ( ) { if ( ! $ this -> users ) { $ userStorage = $ this -> entityTypeManager -> getStorage ( 'user' ) ; $ this -> users = $ userStorage -> loadByProperties ( [ 'status' => true ] ) ; } return array_rand ( $ this -> users ) ; }
Retrieve a random Uid of enabled users .
35,951
protected function getMultisite ( ) { $ sites = [ ] ; $ multiSiteFile = sprintf ( '%s/sites/sites.php' , $ this -> appRoot ) ; if ( file_exists ( $ multiSiteFile ) ) { include $ multiSiteFile ; } if ( ! $ sites ) { $ this -> getIo ( ) -> error ( $ this -> trans ( 'commands.debug.multisite.messages.no-multisites' ) ) ; ...
Get all Multisites .
35,952
protected function moveSettings ( ) { try { if ( ! $ this -> fs -> exists ( $ this -> appRoot . '/sites/' . $ this -> directory . '/settings.php' ) ) { $ this -> fs -> copy ( $ this -> appRoot . '/sites/' . $ this -> uri . '/settings.php' , $ this -> appRoot . '/sites/' . $ this -> directory . '/settings.php' ) ; $ thi...
Move the settings . php file to new directory .
35,953
protected function editSettings ( ) { $ multiSiteSettingsFile = sprintf ( '%s/sites/' . $ this -> explodeDirectory [ 0 ] . '/settings.php' , $ this -> appRoot ) ; if ( ! $ this -> fs -> exists ( $ multiSiteSettingsFile ) ) { $ multiSiteSettingsFile = sprintf ( '%s/sites/' . $ this -> directory . '/settings.php' , $ thi...
Edit the settings . php file to change the database parameters because the settings . php file was moved .
35,954
public function recurse_copy ( $ source , $ destination ) { $ directory = opendir ( $ source ) ; $ this -> fs -> mkdir ( $ destination , 0755 ) ; while ( false !== ( $ file = readdir ( $ directory ) ) ) { if ( ( $ file != '.' ) && ( $ file != '..' ) ) { if ( is_dir ( $ source . '/' . $ file ) ) { $ this -> recurse_copy...
Custom function to recursively copy all file and folders in new destination
35,955
protected function getLegacyDrupalVersion ( Connection $ connection ) { if ( $ connection -> schema ( ) -> tableExists ( 'system' ) ) { try { $ version_string = $ connection -> query ( 'SELECT schema_version FROM {system} WHERE name = :module' , [ ':module' => 'system' ] ) -> fetchField ( ) ; if ( $ version_string && $...
Determine what version of Drupal the source database contains copied from \ Drupal \ migrate_upgrade \ MigrationCreationTrait
35,956
public function create ( $ vocabularies , $ limit , $ nameWords ) { $ siteVocabularies = $ this -> drupalApi -> getVocabularies ( ) ; $ terms = [ ] ; for ( $ i = 0 ; $ i < $ limit ; $ i ++ ) { try { $ vocabulary = $ vocabularies [ array_rand ( $ vocabularies ) ] ; $ term = $ this -> entityTypeManager -> getStorage ( 't...
Create and returns an array of new Terms .
35,957
private function deleteRole ( $ roles ) { $ result = [ ] ; try { foreach ( $ roles as $ value ) { $ role = $ this -> entityTypeManager -> getStorage ( 'user_role' ) -> load ( $ value ) ; $ this -> entityTypeManager -> getStorage ( 'user_role' ) -> delete ( [ $ role ] ) ; $ result [ 'success' ] [ ] = [ 'role-id' => $ va...
Remove and returns an array of deleted roles
35,958
protected function getClassMethods ( $ class ) { $ classReflection = new \ ReflectionClass ( $ class ) ; $ methods = $ classReflection -> getMethods ( ) ; $ metaData = [ ] ; $ methodData = [ ] ; foreach ( $ methods as $ method ) { $ methodData [ 'name' ] = $ method -> getName ( ) ; $ filename = $ method -> getFileName ...
Get data for the methods of a class .
35,959
protected function getPluginAnnotationProperties ( $ pluginAnnotationClass ) { $ annotationReflection = new \ ReflectionClass ( $ pluginAnnotationClass ) ; $ propertiesReflection = $ annotationReflection -> getProperties ( \ ReflectionProperty :: IS_PUBLIC ) ; $ pluginProperties = [ ] ; $ annotationPropertyMetadata = [...
Get the list of properties from an annotation class .
35,960
protected function createInfoString ( $ project_info ) { $ remote_path = isset ( $ project_info -> files [ 'remote' ] -> uri ) ? $ project_info -> files [ 'remote' ] -> uri : false ; $ local_path = isset ( $ project_info -> files [ 'local' ] -> uri ) ? $ project_info -> files [ 'local' ] -> uri : false ; if ( strpos ( ...
Provides debug info for projects in case translation files are not found .
35,961
protected function projectsStatus ( ) { $ status_report = [ ] ; $ status = locale_translation_get_status ( ) ; foreach ( $ status as $ project_id => $ project ) { foreach ( $ project as $ langcode => $ project_info ) { $ info = '' ; if ( $ project_info -> type == LOCALE_TRANSLATION_LOCAL || $ project_info -> type == LO...
LOCALE_TRANSLATION_REMOTE and LOCALE_TRANSLATION_LOCAL indicate available new translations LOCALE_TRANSLATION_CURRENT indicate that the current translation is them most recent .
35,962
private function getCallbackReturnList ( $ service , $ method , $ args ) { if ( $ args != null ) { $ parsedArgs = json_decode ( $ args , true ) ; if ( ! is_array ( $ parsedArgs ) ) { $ parsedArgs = explode ( ',' , $ args ) ; } } else { $ parsedArgs = null ; } $ serviceInstance = \ Drupal :: service ( $ service ) ; if (...
Get callback list .
35,963
private function getServiceList ( $ tag = null ) { if ( $ tag ) { return $ this -> getServiceListByTag ( $ tag ) ; } $ services = [ ] ; $ serviceDefinitions = $ this -> container -> getDefinitions ( ) ; foreach ( $ serviceDefinitions as $ serviceId => $ serviceDefinition ) { $ services [ ] = [ $ serviceId , $ serviceDe...
Get service list .
35,964
private function getServiceListByTag ( $ tag ) { $ services = [ ] ; $ serviceIds = [ ] ; $ serviceDefinitions = $ this -> container -> getDefinitions ( ) ; foreach ( $ tag as $ tagId ) { $ serviceIds = array_merge ( $ serviceIds , array_keys ( $ this -> container -> findTaggedServiceIds ( $ tagId ) ) ) ; } foreach ( $ ...
Get service list by a tag .
35,965
private function addTranslationWrapper ( $ translationString , $ color = ContainerCommand :: YELLOW ) { return $ this -> addWrapper ( $ this -> trans ( $ translationString ) , $ color ) ; }
Adds green color wrapper .
35,966
private function getParameterList ( ) { return array_filter ( $ this -> container -> getParameterBag ( ) -> all ( ) , function ( $ name ) { if ( preg_match ( '/^container\./' , $ name ) ) { return false ; } if ( preg_match ( '/^drupal\./' , $ name ) ) { return false ; } if ( preg_match ( '/^console\./' , $ name ) ) { r...
Get parameter list .
35,967
protected function bootDrupalConsoleCore ( ) { $ drupal = new DrupalConsoleCore ( $ this -> drupalFinder -> getComposerRoot ( ) , $ this -> drupalFinder -> getDrupalRoot ( ) , $ this -> drupalFinder ) ; return $ drupal -> boot ( ) ; }
Builds and boot a DrupalConsoleCore object
35,968
protected function shouldRedirectToDrupalCore ( $ container ) { if ( ! Database :: getConnectionInfo ( ) ) { return true ; } if ( ! $ container -> has ( 'database' ) ) { return true ; } return ! $ container -> get ( 'database' ) -> schema ( ) -> tableExists ( 'sessions' ) ; }
Validate if flow should redirect to DrupalCore
35,969
private function getAllConfigNames ( ) { if ( $ this -> allConfig ) { return $ this -> allConfig ; } foreach ( $ this -> configFactory -> listAll ( ) as $ name ) { $ this -> allConfig [ ] = $ name ; } return $ this -> allConfig ; }
Retrieve configuration names form cache or service factory .
35,970
private function yieldAllConfig ( ) { $ this -> allConfig = $ this -> allConfig ? : $ this -> getAllConfigNames ( ) ; foreach ( $ this -> allConfig as $ name ) { yield $ name ; } }
Yield configuration names .
35,971
private function removeConfig ( $ name ) { try { $ this -> configFactory -> getEditable ( $ name ) -> delete ( ) ; } catch ( \ Exception $ e ) { throw new RuntimeException ( $ e -> getMessage ( ) ) ; } }
Delete given config name .
35,972
protected function displayPluginData ( $ pluginType , $ pluginId ) { switch ( $ pluginType ) { case 'field.field_type' : $ this -> getFieldTypeData ( $ pluginId ) ; break ; case 'field.formatter' : $ this -> getFieldFormatterData ( $ pluginId ) ; break ; case 'field.widget' : $ this -> getFieldWidgetData ( $ pluginId )...
Displays additional plugin data .
35,973
protected function getFieldTypeData ( $ pluginId ) { $ settings = $ this -> container -> get ( 'plugin.manager.field.field_type' ) -> getDefaultFieldSettings ( $ pluginId ) ; $ this -> displaySettingsTable ( $ settings ) ; }
Get field type plugin additional data .
35,974
protected function getFieldFormatterData ( $ pluginId ) { $ settings = $ this -> container -> get ( 'plugin.manager.field.formatter' ) -> getDefaultSettings ( $ pluginId ) ; $ this -> displaySettingsTable ( $ settings ) ; }
Get field formatter plugin additional data .
35,975
protected function getFieldWidgetData ( $ pluginId ) { $ settings = $ this -> container -> get ( 'plugin.manager.field.widget' ) -> getDefaultSettings ( $ pluginId ) ; $ this -> displaySettingsTable ( $ settings ) ; }
Get field widget plugin additional data .
35,976
protected function displaySettingsTable ( $ settings ) { $ tableHeader = [ $ this -> trans ( 'commands.debug.plugin.table-headers.setting' ) , $ this -> trans ( 'commands.debug.plugin.table-headers.definition-value' ) ] ; $ tableRows = $ this -> prepareTableRows ( $ settings ) ; if ( count ( $ tableRows ) > 0 ) { $ thi...
Displays settings table .
35,977
private function createRole ( $ rolename , $ machine_name ) { $ role = Role :: create ( [ 'id' => $ machine_name , 'label' => $ rolename , 'originalId' => $ machine_name ] ) ; $ result = [ ] ; try { $ role -> save ( ) ; $ result [ 'success' ] [ ] = [ 'role-id' => $ role -> id ( ) , 'role-name' => $ role -> get ( 'label...
Create and returns an array of new role
35,978
protected function createTableHeader ( ) { return [ $ this -> trans ( 'commands.database.log.common.messages.event-id' ) , $ this -> trans ( 'commands.database.log.common.messages.type' ) , $ this -> trans ( 'commands.database.log.common.messages.date' ) , $ this -> trans ( 'commands.database.log.common.messages.messag...
Generic logging table header
35,979
protected function formatMessage ( \ stdClass $ event ) { $ message = false ; if ( isset ( $ event -> message , $ event -> variables ) ) { if ( $ event -> variables === 'N;' ) { return $ event -> message ; } return $ this -> stringTranslation -> translate ( $ event -> message , unserialize ( $ event -> variables ) ) ; ...
Formats a database log message .
35,980
public function moduleRequirement ( array $ module ) { $ fail = false ; foreach ( $ module as $ module_name ) { module_load_install ( $ module_name ) ; if ( $ requirements = \ Drupal :: moduleHandler ( ) -> invoke ( $ module_name , 'requirements' , [ 'install' ] ) ) { foreach ( $ requirements as $ requirement ) { if ( ...
Verify that install requirements for a list of modules are met .
35,981
public function create ( $ limit ) { $ roles = [ ] ; for ( $ i = 0 ; $ i < $ limit ; $ i ++ ) { try { $ rolename = $ this -> getRandom ( ) -> word ( mt_rand ( 6 , 12 ) ) ; $ role = $ this -> entityTypeManager -> getStorage ( 'user_role' ) -> create ( [ 'id' => $ rolename , 'label' => $ rolename , 'originalId' => $ role...
Create and returns an array of new Roles .
35,982
private function getBundleFields ( $ entityTypeId , $ bundle ) { $ fields = [ ] ; if ( ! empty ( $ entityTypeId ) && ! empty ( $ bundle ) ) { $ fields = array_filter ( $ this -> entityFieldManager -> getFieldDefinitions ( $ entityTypeId , $ bundle ) , function ( $ fieldDefinition ) { return $ fieldDefinition instanceof...
Helper function to get the field definitions .
35,983
public function create ( $ limit , $ nameWords ) { $ vocabularies = [ ] ; for ( $ i = 0 ; $ i < $ limit ; $ i ++ ) { try { $ vocabulary = $ this -> entityTypeManager -> getStorage ( 'taxonomy_vocabulary' ) -> create ( [ 'name' => $ this -> getRandom ( ) -> sentences ( mt_rand ( 1 , $ nameWords ) , true ) , 'description...
Create and returns an array of new Vocabularies .
35,984
protected function getLanguage ( ) { $ output = [ ] ; $ default_id = $ this -> languageManager -> getDefaultLanguage ( ) -> getId ( ) ; foreach ( $ this -> languageManager -> getLanguages ( ) as $ key => $ value ) { if ( $ default_id == $ key ) { $ output [ ] = '' ; } else { $ output [ ] = 'language.' . $ value -> getI...
Get the languague enable .
35,985
protected function outputDiffTable ( array $ change_list ) { $ header = [ $ this -> trans ( 'commands.config.diff.table.headers.collection' ) , $ this -> trans ( 'commands.config.diff.table.headers.config-name' ) , $ this -> trans ( 'commands.config.diff.table.headers.operation' ) , ] ; $ rows = [ ] ; foreach ( $ chang...
Ouputs a table of configuration changes .
35,986
public function validateEventExist ( $ event , $ events ) { if ( $ event == '' ) { return null ; } if ( ! in_array ( $ event , array_values ( $ events ) ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Event "%s" is invalid.' , $ event ) ) ; } return $ event ; }
Validate if event name exist .
35,987
public function validateSpaces ( $ name ) { $ string = $ this -> removeSpaces ( $ name ) ; if ( $ string == $ name ) { return $ name ; } else { throw new \ InvalidArgumentException ( sprintf ( 'The name "%s" is invalid, spaces between words are not allowed.' , $ name ) ) ; } }
Validates if class name have spaces between words .
35,988
public function validateHttpMethods ( $ httpMethods , $ availableHttpMethods ) { if ( empty ( $ httpMethods ) ) { return null ; } $ missing_methods = array_diff ( array_values ( $ httpMethods ) , array_keys ( $ availableHttpMethods ) ) ; if ( ! empty ( $ missing_methods ) ) { throw new \ InvalidArgumentException ( spri...
Validate if http methods exist .
35,989
private function validateRole ( $ role , $ roles , $ checkExistence = true ) { if ( empty ( $ roles ) ) { return null ; } $ roleExists = array_key_exists ( $ role , $ roles ) ; $ condition = $ checkExistence ? ! $ roleExists : $ roleExists ; if ( $ condition ) { $ errorMessage = $ checkExistence ? "Role %s doesn't exis...
Validates role existence or non existence .
35,990
public function create ( $ roles , $ limit , $ password , $ timeRange ) { $ siteRoles = $ this -> drupalApi -> getRoles ( ) ; $ users = [ ] ; for ( $ i = 0 ; $ i < $ limit ; $ i ++ ) { try { $ username = $ this -> getRandom ( ) -> word ( mt_rand ( 6 , 12 ) ) ; $ user = $ this -> entityTypeManager -> getStorage ( 'user'...
Create and returns an array of new Users .
35,991
public function withFile ( $ key , $ path , $ mimeType = '' , $ postFileName = '' ) { $ fileData = array ( 'fileName' => $ path , 'mimeType' => $ mimeType , 'postFileName' => $ postFileName , ) ; $ this -> packageOptions [ 'files' ] [ $ key ] = $ fileData ; return $ this -> containsFile ( ) ; }
Add a file to the request
35,992
public function withProxy ( $ proxy , $ port = '' , $ type = '' , $ username = '' , $ password = '' ) { $ this -> withOption ( 'PROXY' , $ proxy ) ; if ( ! empty ( $ port ) ) { $ this -> withOption ( 'PROXYPORT' , $ port ) ; } if ( ! empty ( $ type ) ) { $ this -> withOption ( 'PROXYTYPE' , $ type ) ; } if ( ! empty ( ...
Enable Proxy for the cURL request
35,993
protected function setPostParameters ( ) { $ this -> curlOptions [ 'POST' ] = true ; $ parameters = $ this -> packageOptions [ 'data' ] ; if ( ! empty ( $ this -> packageOptions [ 'files' ] ) ) { foreach ( $ this -> packageOptions [ 'files' ] as $ key => $ file ) { $ parameters [ $ key ] = $ this -> getCurlFileValue ( ...
Add POST parameters to the curlOptions array
35,994
protected function forgeOptions ( ) { $ results = array ( ) ; foreach ( $ this -> curlOptions as $ key => $ value ) { $ arrayKey = constant ( 'CURLOPT_' . $ key ) ; if ( ! $ this -> packageOptions [ 'containsFile' ] && $ key == 'POSTFIELDS' && is_array ( $ value ) ) { $ results [ $ arrayKey ] = http_build_query ( $ val...
Convert the curlOptions to an array of usable options for the cURL request
35,995
protected function appendDataToURL ( ) { $ parameterString = '' ; if ( is_array ( $ this -> packageOptions [ 'data' ] ) && count ( $ this -> packageOptions [ 'data' ] ) != 0 ) { $ parameterString = '?' . http_build_query ( $ this -> packageOptions [ 'data' ] , null , '&' ) ; } return $ this -> curlOptions [ 'URL' ] .= ...
Append set data to the query string for GET and DELETE cURL requests
35,996
public function to_string ( ) : string { return 'oauth_token=' . Util :: urlencode_rfc3986 ( $ this -> key ) . '&oauth_token_secret=' . Util :: urlencode_rfc3986 ( $ this -> secret ) ; }
generates the basic string serialization of a token that a server would respond to request_token and access_token calls with
35,997
public function authenticate ( ) : bool { try { $ res = $ this -> request ( 'account/verify_credentials' , 'GET' ) ; return ! empty ( $ res -> id ) ; } catch ( Exception $ e ) { if ( $ e -> getCode ( ) === 401 ) { return false ; } throw $ e ; } }
Tests if user credentials are valid .
35,998
public function cachedRequest ( string $ resource , array $ data = [ ] , $ cacheExpire = null ) { if ( ! self :: $ cacheDir ) { return $ this -> request ( $ resource , 'GET' , $ data ) ; } if ( $ cacheExpire === null ) { $ cacheExpire = self :: $ cacheExpire ; } $ cacheFile = self :: $ cacheDir . '/twitter.' . md5 ( $ ...
Cached HTTP request .
35,999
public static function clickable ( stdClass $ status ) : string { $ all = [ ] ; foreach ( $ status -> entities -> hashtags as $ item ) { $ all [ $ item -> indices [ 0 ] ] = [ "https://twitter.com/search?q=%23$item->text" , "#$item->text" , $ item -> indices [ 1 ] ] ; } foreach ( $ status -> entities -> urls as $ item )...
Makes twitter links