idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
3,300
public function make ( $ key ) { switch ( $ key ) { case 'config' : return $ this -> config ; case 'em' : return $ this -> entityManager ; case 'extension' : return $ this -> extensionManager ; case 'migration' : return $ this -> migrationManager ; case 'log' : return $ this -> logger ; case 'file' : return $ this -> f...
application s interface maker
3,301
final public function start ( ) { try { $ this -> register ( ) ; $ this -> boot ( ) ; } catch ( HttpValidationException $ exception ) { $ validations = json_decode ( $ exception -> getMessage ( ) , true ) ; response ( $ validations , $ exception -> getCode ( ) ) -> send ( ) ; } catch ( HttpException $ exception ) { res...
run all the services
3,302
public function dispatch ( $ event ) { if ( $ event instanceof AbstractEvent ) { $ this -> dispatcher -> dispatch ( $ event -> getEventName ( ) , $ event ) ; } else { $ this -> dispatcher -> dispatch ( $ event ) ; } return $ this ; }
dispatch an event
3,303
public function listen ( $ event , $ handler ) { if ( $ event instanceof AbstractEvent ) { $ event = $ event -> getEventName ( ) ; } $ this -> dispatcher -> addListener ( $ event , $ handler ) ; return $ this ; }
listen an event
3,304
protected function config ( $ host , $ database , $ user , $ password ) { return [ 'host' => $ this -> setLocal ( $ host ? $ host : Config :: get ( 'database.host' ) ) , 'database' => $ database ? $ database : Config :: get ( 'database.database' ) , 'user' => $ user ? $ user : Config :: get ( 'database.username' ) , 'p...
get Connection configuration .
3,305
public function ConversationQuery ( $ ViewingUserID , $ Join = '' ) { $ this -> SQL -> Select ( 'c.*' ) -> Select ( 'lm.InsertUserID' , '' , 'LastMessageUserID' ) -> Select ( 'lm.DateInserted' , '' , 'DateLastMessage' ) -> Select ( 'lm.Body' , '' , 'LastMessage' ) -> Select ( 'lm.Format' ) -> Select ( 'lmu.Name' , '' ,...
Build generic part of conversation query .
3,306
public function Get ( $ ViewingUserID , $ Offset = '0' , $ Limit = '' ) { if ( $ Limit == '' ) $ Limit = Gdn :: Config ( 'Conversations.Conversations.PerPage' , 30 ) ; $ Offset = ! is_numeric ( $ Offset ) || $ Offset < 0 ? 0 : $ Offset ; $ Data = $ this -> SQL -> Select ( 'c.*' ) -> Select ( 'uc.CountReadMessages' ) ->...
Get list of conversations .
3,307
public function GetCount ( $ ViewingUserID , $ Wheres = '' ) { if ( is_array ( $ Wheres ) ) $ this -> SQL -> Where ( $ Wheres ) ; return $ this -> SQL -> Select ( 'uc.UserID' , 'count' , 'Count' ) -> From ( 'UserConversation uc' ) -> Where ( 'uc.UserID' , $ ViewingUserID ) -> Get ( ) -> Value ( 'Count' , 0 ) ; }
Get number of conversations involving current user .
3,308
public function GetID ( $ ConversationID , $ ViewingUserID = FALSE ) { $ Conversation = $ this -> GetWhere ( array ( 'ConversationID' => $ ConversationID ) ) -> FirstRow ( DATASET_TYPE_ARRAY ) ; if ( $ ViewingUserID ) { $ Data = $ this -> SQL -> GetWhere ( 'UserConversation' , array ( 'ConversationID' => $ Conversation...
Get meta data of a single conversation .
3,309
public function GetRecipients ( $ ConversationID , $ IgnoreUserID = '0' ) { $ Data = $ this -> SQL -> Select ( 'uc.*' ) -> From ( 'UserConversation uc' ) -> Where ( 'uc.ConversationID' , $ ConversationID ) -> Get ( ) ; Gdn :: UserModel ( ) -> JoinUsers ( $ Data -> Result ( ) , array ( 'UserID' ) ) ; return $ Data ; }
Get all users involved in conversation .
3,310
public function Clear ( $ ConversationID , $ ClearingUserID ) { $ this -> SQL -> Update ( 'UserConversation' ) -> Set ( 'Deleted' , 1 ) -> Set ( 'DateLastViewed' , Gdn_Format :: ToDateTime ( ) ) -> Where ( 'UserID' , $ ClearingUserID ) -> Where ( 'ConversationID' , $ ConversationID ) -> Put ( ) ; $ this -> CountUnread ...
Clear a conversation for a specific user id .
3,311
public function MarkRead ( $ ConversationID , $ ReadingUserID ) { $ this -> SQL -> Update ( 'UserConversation uc' ) -> Join ( 'Conversation c' , 'c.ConversationID = uc.ConversationID' ) -> Set ( 'uc.CountReadMessages' , 'c.CountMessages' , FALSE ) -> Set ( 'uc.DateLastViewed' , Gdn_Format :: ToDateTime ( ) ) -> Set ( '...
Update a conversation as read for a specific user id .
3,312
public function AddUserToConversation ( $ ConversationID , $ UserID ) { if ( ! is_array ( $ UserID ) ) $ UserID = array ( $ UserID ) ; $ OldContributorData = $ this -> GetRecipients ( $ ConversationID ) ; $ OldContributorData = Gdn_DataSet :: Index ( $ OldContributorData , 'UserID' ) ; $ AddedUserIDs = array ( ) ; $ Co...
Add another user to the conversation .
3,313
public function createUser ( string $ username , string $ email , string $ password ) : bool { $ existing = $ this -> getUser ( - 1 , $ username , $ email ) ; if ( $ existing !== null ) { return false ; } else { $ username = htmlspecialchars ( $ username , ENT_QUOTES , 'UTF-8' ) ; $ email = htmlspecialchars ( $ email ,...
Creates a new user provided that user does not already exist or use the same email address or username
3,314
public function getUser ( int $ id , string $ username , string $ email ) : ? User { $ stmt = $ this -> db -> prepare ( "SELECT id, username, email, pw_hash, confirmation " . "FROM accounts " . "WHERE id=? " . "OR username=? " . "OR email=?;" ) ; $ stmt -> bind_param ( "iss" , $ id , $ username , $ email ) ; $ stmt -> ...
Tries to retrieve a user from the database . If the user does not exist this method returns null .
3,315
public function deleteUser ( User $ user , string $ password ) : bool { if ( $ user -> doesPasswordMatch ( $ password ) ) { $ stmt = $ this -> db -> prepare ( "DELETE FROM accounts " . "WHERE id=? AND username=? AND email=?;" ) ; $ stmt -> bind_param ( "iss" , $ user -> id , $ user -> username , $ user -> email ) ; $ s...
Deletes a user from the database completely
3,316
public function getAllUsers ( ) : array { $ result = $ this -> db -> query ( "SELECT id FROM accounts;" ) ; $ users = [ ] ; foreach ( $ result -> fetch_all ( MYSQLI_ASSOC ) as $ user ) { $ users [ ( int ) $ user [ "id" ] ] = $ this -> getUserFromId ( ( int ) $ user [ "id" ] ) ; } return $ users ; }
Retrieves all users from the database
3,317
public static function singularize ( $ word ) { $ singular = array ( '/(quiz)zes$/i' => '\1' , '/(matr)ices$/i' => '\1ix' , '/(vert|ind)ices$/i' => '\1ex' , '/^(ox)en/i' => '\1' , '/(alias|status)es$/i' => '\1' , '/([octop|vir])i$/i' => '\1us' , '/(cris|ax|test)es$/i' => '\1is' , '/(shoe)s$/i' => '\1' , '/(o)es$/i' => ...
Singularizes English nouns .
3,318
public function init ( ) { if ( ! empty ( $ this -> registry [ $ this -> section ] ) ) { throw new RegistryException ( RegistryException :: DUPLICATE_INITIATION_ATTEMPT_TEXT . '(section: ' . $ this -> section . ')' , RegistryException :: DUPLICATE_INITIATION_ATTEMPT_CODE ) ; } $ this -> registry [ $ this -> section ] =...
Initates a registry .
3,319
public function isRegistered ( $ identifier ) { $ this -> verifySectionName ( $ identifier ) ; return array_key_exists ( $ identifier , $ this -> registry [ $ this -> section ] ) ; }
Determines if the given identifier refers to a world .
3,320
public function addVisit ( \ BlackForest \ PiwikBundle \ Entity \ PiwikVisit $ visit ) { $ this -> visit [ ] = $ visit ; return $ this ; }
Add visit .
3,321
public function removeVisit ( \ BlackForest \ PiwikBundle \ Entity \ PiwikVisit $ visit ) { return $ this -> visit -> removeElement ( $ visit ) ; }
Remove visit .
3,322
public function setCountry ( \ BlackForest \ PiwikBundle \ Entity \ PiwikCountry $ country = null ) { $ this -> country = $ country ; return $ this ; }
Set country .
3,323
public static function listFilesRecursive ( $ dirPath , \ Closure $ filter = null ) { $ files = [ ] ; foreach ( new RecursiveIteratorIterator ( new RecursiveDirectoryIterator ( $ dirPath , FilesystemIterator :: SKIP_DOTS ) , RecursiveIteratorIterator :: CHILD_FIRST ) as $ finfo ) { if ( $ finfo -> isFile ( ) ) { if ( $...
Iterates over a tree and takes all files . Files can be filtered with a function that will receive a SplFileInfo object as parameter and must return true for the file to be included in the results . Finally returns an array of SplFileInfo objects .
3,324
public static function listDirsRecusrive ( $ root ) { $ dirs = [ ] ; foreach ( new RecursiveIteratorIterator ( new RecursiveDirectoryIterator ( $ root , FilesystemIterator :: SKIP_DOTS ) , RecursiveIteratorIterator :: CHILD_FIRST ) as $ path ) { if ( $ path -> isDir ( ) ) { $ dirs [ ] = $ path -> getPathname ( ) ; } } ...
Lists all directories and subdirectories found in a path .
3,325
public function onPreCreate ( UserEvent $ event ) { $ user = $ event -> getResource ( ) ; if ( 0 === strlen ( $ user -> getPlainPassword ( ) ) ) { $ this -> userManager -> generatePassword ( $ user ) ; $ user -> setEnabled ( true ) ; $ password = $ user -> getPlainPassword ( ) ; $ event -> addMessage ( new ResourceMess...
Pre create resource event handler .
3,326
public function onPostCreate ( UserEvent $ event ) { if ( ! $ event -> hasData ( 'password' ) ) { return ; } $ user = $ event -> getResource ( ) ; if ( ! $ user -> getSendCreationEmail ( ) ) { return ; } if ( 0 < $ this -> mailer -> sendCreationEmailMessage ( $ user , $ event -> getData ( 'password' ) ) ) { $ event -> ...
Post create resource event handler .
3,327
public function onPreUpdate ( UserEvent $ event ) { $ user = $ event -> getResource ( ) ; $ this -> userManager -> updatePassword ( $ user ) ; $ this -> userManager -> updateCanonicalFields ( $ user ) ; }
Pre update resource event handler .
3,328
public function onPostUpdate ( UserEvent $ event ) { if ( ! $ event -> hasData ( 'password' ) ) { return ; } $ user = $ event -> getResource ( ) ; if ( 0 < $ this -> mailer -> sendNewPasswordEmailMessage ( $ user , $ event -> getData ( 'password' ) ) ) { $ event -> addMessage ( new ResourceMessage ( 'ekyna_user.user.ev...
Post update resource event handler .
3,329
public function cardDisplayFilter ( CardDecoratedInterface $ object , string $ property ) { $ decorator = $ object -> getCardDecorator ( ) ; $ accessor = PropertyAccess :: createPropertyAccessor ( ) ; if ( ! $ accessor -> isReadable ( $ decorator , $ property ) ) { throw new InvalidCardDecoratorPropertyException ( $ de...
Filter to get card decorated property
3,330
private function _prepareTables ( array $ tablesArray ) { if ( count ( $ tablesArray ) === 0 ) { throw new \ Exception ( '"table"-method of the statement have to invoked before!' ) ; } $ tables = ' ' ; foreach ( $ tablesArray as $ table ) { $ tables .= $ table -> getExpression ( ) . ', ' ; } $ tables = substr ( $ table...
Fill the property tables in a well format for the process method .
3,331
private function _prepareColumns ( array $ columnsArray ) { if ( count ( $ columnsArray ) === 0 ) { throw new \ Exception ( '"column"-method of the statement have to invoked before!' ) ; } $ columns = ' ' ; foreach ( $ columnsArray as $ column ) { $ columns .= $ column -> getExpression ( ) . ', ' ; } $ columns = substr...
Fill the property columns in a well format for the process method .
3,332
private function _prepareGroupBy ( array $ groupByArray ) { if ( count ( $ groupByArray ) === 1 ) { foreach ( $ groupByArray as $ orderMode => $ column ) { $ this -> groupBy = 'GROUP BY ' . $ column -> getColumnName ( ) . ' ' ; if ( is_string ( $ orderMode ) ) { $ this -> groupBy .= $ orderMode . ' ' ; } } } }
Fill the property groupBy in a well format for the process method .
3,333
private function _prepareJoin ( array $ joinArray ) { if ( count ( $ joinArray ) > 0 ) { $ factory = $ this -> expressionBuilderFactory -> create ( $ joinArray [ 0 ] ) ; foreach ( $ joinArray as $ number => $ join ) { if ( $ number === 0 ) { $ this -> join = $ factory -> build ( ) ; } else { $ this -> join .= $ factory...
Fill the property join in a well format for the process method .
3,334
private function _prepareLimit ( array $ limitArray ) { if ( count ( $ limitArray ) === 1 ) { foreach ( $ limitArray as $ begin => $ amount ) { $ this -> limit = 'LIMIT ' . $ begin . ', ' . $ amount . ' ' ; } } }
Fill the property limit in a well format for the process method .
3,335
private function require_file ( $ path ) { $ path = realpath ( $ path ) ; if ( file_exists ( $ path ) ) { require_once $ path ; $ opcache_enabled = ini_get ( 'opcache.enable' ) ; $ opcache_cli_enabled = ini_get ( 'opcache.enable_cli' ) ; if ( ( php_sapi_name ( ) == 'cli' and $ opcache_cli_enabled ) or ( php_sapi_name (...
Require a file
3,336
public function add ( BroadcasterInterface $ broadcaster ) { if ( $ this -> has ( $ broadcaster -> getName ( ) ) ) { throw new InvalidArgumentException ( sprintf ( 'Broadcaster with name "%s" already registered.' , $ broadcaster -> getName ( ) ) ) ; } $ this -> broadcasters [ $ broadcaster -> getName ( ) ] = $ broadcas...
Register a broadcaster .
3,337
public function runInstallers ( Event $ event ) { foreach ( $ this -> finder -> getDependentPackages ( $ event -> isDevMode ( ) ) as $ package ) { $ this -> runner -> runInstallers ( $ package , $ event -> isDevMode ( ) ) ; } }
Run the installers
3,338
public function loadConfig ( $ name ) { if ( ! $ this -> configExists ( $ name ) ) $ this -> config [ $ name ] = $ this -> getConfigObjectFromDatabase ( $ name ) ; }
load config use reloadConfig if you want to get the data fresh from the database
3,339
private function reloadConfig ( $ name , $ data = null , $ json = false ) { if ( empty ( $ data ) ) { $ this -> config [ $ name ] = $ this -> getConfigObjectFromDatabase ( $ name ) ; } else { $ this -> config [ $ name ] = $ this -> createConfigObject ( $ name , $ data , $ json ) ; } }
reload config from database
3,340
public function loadConfigsByHook ( $ hook , $ reload = false ) { $ data = $ this -> app -> db -> conn ( ) -> prepare ( 'SELECT * FROM ' . $ this -> app -> db -> getPrefix ( ) . 'config WHERE `config_loadhook` = ?' ) ; $ data -> execute ( array ( $ hook ) ) ; $ data = $ data -> fetchAll ( \ PDO ...
load configs by hook
3,341
private function createConfigObject ( $ name , $ data , $ json ) { $ class_name = self :: class . '\\Config' . ucfirst ( strtolower ( $ name ) ) ; if ( ! class_exists ( $ class_name ) ) { $ class_name = self :: class . '\\ConfigData' ; } return new $ class_name ( $ data , $ json ) ; }
create config object
3,342
private function getConfigObjectFromDatabase ( $ name ) { $ config = $ this -> app -> db -> conn ( ) -> prepare ( 'SELECT * FROM ' . $ this -> app -> db -> getPrefix ( ) . 'config WHERE `config_name` = ? LIMIT 1' ) ; $ config -> execute ( array ( $ name ) ) ; $ config = $ config -> fetch ( \ PD...
create config object from db
3,343
public function configObject ( $ name ) { if ( ! $ this -> configExists ( $ name ) ) { $ this -> reloadConfig ( $ name ) ; } return $ this -> config [ $ name ] ; }
get access on a config object
3,344
private function loadVersion ( ) { $ headers = $ this -> request -> header ( ) ; if ( isset ( $ headers [ 'api-version' ] ) ) { $ rawVersion = array_shift ( $ headers [ 'api-version' ] ) ; $ version = strtolower ( $ rawVersion ) ; if ( is_numeric ( $ version ) ) { $ this -> version = 'v' . $ version ; } else { $ this -...
Resolve the requested api version .
3,345
public function has ( $ event ) { list ( $ event , $ payload ) = $ this -> parseEventAndPayload ( $ event , [ ] ) ; return array_key_exists ( $ event , $ this -> listeners ) ; }
Check if event has listeners .
3,346
protected function getBundleName ( ) { $ pattern = "/(.*)Bundle/" ; $ matches = array ( ) ; preg_match ( $ pattern , $ this -> getRequest ( ) -> get ( '_controller' ) , $ matches ) ; return empty ( $ matches ) ? null : $ matches [ 1 ] ; }
Get the bundle name
3,347
public function each ( \ Closure $ callback ) { foreach ( $ this -> items as $ name => $ properties ) { if ( $ callback ( $ properties , $ name ) === false ) { break ; } } return $ this ; }
Each module items
3,348
public function installed ( $ name ) { if ( ! is_array ( $ name ) ) { $ name = [ $ name ] ; } if ( ! count ( $ name ) ) { return false ; } foreach ( $ name as $ module_name ) { if ( is_numeric ( $ module_name ) ) { if ( ! $ this -> offsetExists ( $ module_name ) ) { return false ; } } else if ( $ this -> getId ( $ modu...
Has module or modules install .
3,349
private static function getHydratorClosure ( $ object ) { if ( ! isset ( self :: $ hydratorClosure ) ) { self :: $ hydratorClosure = function ( $ object , array $ data ) { foreach ( $ data as $ name => $ value ) { $ object -> $ name = $ value ; } } ; } $ class = get_class ( $ object ) ; if ( ! isset ( self :: $ hydrato...
Returns a closure for hydration
3,350
private static function getExtractorClosure ( $ object ) { if ( ! isset ( self :: $ extractorClosure ) ) { self :: $ extractorClosure = function ( $ object ) { return get_object_vars ( $ object ) ; } ; } $ class = get_class ( $ object ) ; if ( ! isset ( self :: $ extractorClosureCache [ $ class ] ) ) { self :: $ extrac...
Returns a closure for extraction
3,351
public function validate ( $ plugin ) { if ( ! $ plugin instanceof $ this -> instanceOf ) { throw new InvalidServiceException ( sprintf ( '%s expects only to create instances of %s; %s is invalid' , get_class ( $ this ) , $ this -> instanceOf , ( is_object ( $ plugin ) ? get_class ( $ plugin ) : gettype ( $ plugin ) ) ...
Validate an instance
3,352
public function __isset ( $ property ) { switch ( $ property ) { case 'plurals' : case 'pluralExpr' : return $ this -> $ property ; default : if ( isset ( $ this -> messages [ '[Locale::' . $ property . ']' ] ) ) { return true ; } return isset ( self :: $ defaultProperties [ $ property ] ) ; } }
Whether a property exists and has a value .
3,353
public static function convertExpr ( $ expr ) { preg_match_all ( '/(==|!=|<=|>=|&&|\|\||<<|>>|[-!?:+*\/&|^~%<>()n]|[0-9]+)/' , $ expr , $ matches ) ; $ tokens = $ matches [ 0 ] ; $ expr = '' ; $ stack = array ( ) ; foreach ( $ tokens as $ token ) { if ( $ token == 'n' ) { $ expr .= '$n' ; } elseif ( $ token == ':' ) { ...
Converts simple gettext C expressions to PHP .
3,354
public function extend ( Locale $ l ) { $ this -> messages = array_merge ( $ this -> messages , $ l -> messages ) ; }
Extend this localization with additional messages from another one .
3,355
public function set ( $ messageId , $ translation ) { if ( is_array ( $ translation ) ) { $ this -> messages [ $ messageId ] = $ translation ; } else { if ( ! isset ( $ this -> messages [ $ messageId ] ) ) { $ this -> messages [ $ messageId ] = array ( ) ; } $ this -> messages [ $ messageId ] [ ] = $ translation ; } }
Set translation string .
3,356
public function replacePlaceholders ( $ message , $ values = array ( ) ) { $ length = count ( $ values ) ; $ i = 1 ; foreach ( $ values as $ value ) { if ( is_array ( $ value ) ) { $ message = preg_replace_callback ( '/%' . $ i . '\{(.*?)\}\{(.*?)\}/' , function ( $ matches ) use ( $ value ) { $ length = count ( $ valu...
Replace placeholders in a translation string .
3,357
public static function fromCommand ( CommandInterface $ command ) { $ file = new self ( ) ; $ file -> setParameters ( $ command -> getResponse ( ) -> json ( ) + array ( 'path' => $ command [ 'path' ] ) ) ; $ file -> finishUpload ( ) ; return $ file -> getParameters ( ) ; }
Create a new model instance from a command .
3,358
public function finishUpload ( $ requiredHeaders = array ( ) ) { $ parameters = $ this -> getParameters ( ) ; if ( isset ( $ parameters [ '_requiredHeaders' ] ) ) $ requiredHeaders = $ parameters [ '_requiredHeaders' ] ; $ client = new Client ; $ request = $ client -> put ( $ parameters [ '_uploadURL' ] , $ requiredHea...
Perform the file upload operation .
3,359
protected function doRun ( ) { $ config = $ this -> config ; if ( $ this -> target [ 'id' ] != $ this -> head [ 'id' ] ) { $ this -> canMove ( ) ; $ movingNodes = $ this -> getMovingNodes ( ) ; $ movingNodesRange = $ this -> getMovingNodesRange ( ) ; $ shiftingNodes = $ this -> getShiftingNodes ( ) ; $ shiftingNodesRan...
Run the logic .
3,360
public function get ( ) { if ( null !== $ this -> value ) { return $ this -> value ; } $ key = [ $ this -> getCacheItemPool ( ) -> getPoolName ( ) , $ this -> getKey ( ) ] ; $ key = $ this -> getCacheItemPool ( ) -> getDriver ( ) -> buildKey ( $ key ) ; $ response = $ this -> getCacheItemPool ( ) -> getDriver ( ) -> ge...
Retrieves the value of the item from the cache associated with this objects key .
3,361
public function exists ( ) { $ key = [ $ this -> getCacheItemPool ( ) -> getPoolName ( ) , $ this -> getKey ( ) ] ; $ key = $ this -> getCacheItemPool ( ) -> getDriver ( ) -> buildKey ( $ key ) ; return $ this -> getCacheItemPool ( ) -> getDriver ( ) -> exists ( $ key ) ; }
Confirms if the cache item exists in the cache .
3,362
public function getExpiration ( ) { if ( $ this -> isHit ( ) && null === $ this -> expiration ) { $ key = [ $ this -> getCacheItemPool ( ) -> getPoolName ( ) , $ this -> getKey ( ) ] ; $ key = $ this -> getCacheItemPool ( ) -> getDriver ( ) -> buildKey ( $ key ) ; $ this -> expiration = $ this -> getCacheItemPool ( ) -...
Returns the expiration time of a not - yet - expired cache item .
3,363
public function isValidState ( Model $ Model , $ check , $ valid = array ( ) , $ ruleset = array ( ) ) { $ settings = $ this -> settings [ $ Model -> alias ] [ 'fields' ] ; $ field = current ( array_keys ( ( array ) $ check ) ) ; $ value = current ( ( array ) $ check ) ; if ( empty ( $ ruleset ) ) { $ ruleset = $ valid...
Checks if a given value is a valid state .
3,364
public function createNew ( int $ sourceId , string $ name , $ value , $ type = null ) : array { if ( $ type === null ) { $ type = $ this -> typeInfer ( $ value ) ; } return $ this -> sendPost ( sprintf ( '/profiles/%s/features' , $ this -> userName ) , [ ] , [ 'source_id' => $ sourceId , 'name' => $ name , 'value' => ...
Creates a new feature for the given user .
3,365
public function upsertOne ( int $ sourceId , string $ name , $ value , $ type = null ) : array { if ( $ type === null ) { $ type = $ this -> typeInfer ( $ value ) ; } return $ this -> sendPut ( sprintf ( '/profiles/%s/features' , $ this -> userName ) , [ ] , [ 'source_id' => $ sourceId , 'name' => $ name , 'value' => $...
Tries to update a feature and if it doesnt exists creates a new feature .
3,366
public function updateOne ( int $ featureId , $ value , string $ type ) : array { return $ this -> sendPatch ( sprintf ( '/profiles/%s/features/%s' , $ this -> userName , $ featureId ) , [ ] , [ 'value' => $ value , 'type' => $ type ] ) ; }
Updates a feature given its slug .
3,367
public static function createHash ( $ string ) { $ salt = substr ( str_replace ( '+' , '.' , base64_encode ( pack ( 'N4' , mt_rand ( ) , mt_rand ( ) , mt_rand ( ) , mt_rand ( ) ) ) ) , 0 , 22 ) ; return crypt ( $ string , '$2a$10$' . $ salt . '$' ) ; }
Creates a 60 characters long hash by using the crypt function with the Blowfish algorithm .
3,368
protected function _clearDir ( $ dir ) { $ dirPath = $ this -> Dir -> pwd ( ) . $ dir ; if ( ! $ this -> isExistFolder ( $ dir ) ) { $ this -> err ( "Error : directory {$dir} not exist" ) ; return false ; } if ( ! $ this -> Dir -> delete ( $ dirPath ) ) { $ this -> err ( "Error : delete directory {$dir} failed" ) ; $ t...
Clear a dir
3,369
private function apiRequest ( $ options ) { $ params = new \ DerivativeRequest ( $ this -> getRequest ( ) , $ options ) ; $ api = new \ ApiMain ( $ params ) ; $ api -> execute ( ) ; return $ api -> getResult ( ) -> getResultData ( ) ; }
Send a request to the MediaWiki API .
3,370
private function getTextFromArticle ( $ title ) { $ title = \ Title :: newFromText ( $ title ) ; $ revision = \ Revision :: newFromId ( $ title -> getLatestRevID ( ) ) ; if ( isset ( $ revision ) ) { return \ ContentHandler :: getContentText ( $ revision -> getContent ( \ Revision :: RAW ) ) ; } else { return ; } }
Extract text content from an article .
3,371
public static function getCategoryTree ( \ Title $ title ) { global $ wgCountryCategory ; if ( $ title -> getNamespace ( ) == NS_ADDRESS_NEWS ) { $ title = \ Title :: newFromText ( $ title -> getText ( ) , NS_ADDRESS ) ; } $ parenttree = $ title -> getParentCategoryTree ( ) ; CategoryBreadcrumb :: checkParentCategory (...
Get a category tree from an article .
3,372
public function execute ( $ subPage ) { global $ wgCountryCategory , $ wgTitle ; $ article = new \ Article ( $ wgTitle ) ; $ this -> languageCode = $ article -> getContext ( ) -> getLanguage ( ) -> getCode ( ) ; $ output = $ this -> getOutput ( ) ; $ this -> setHeaders ( ) ; $ this -> outputFocus ( ) ; $ this -> output...
Display the special page .
3,373
public static function rehydrate ( $ serialised , ExecHelper $ execHelper , LoggerInterface $ logger = null ) { $ view = unserialize ( $ serialised ) ; $ view -> setExec ( $ execHelper ) ; $ view -> handleDependencyInjection ( ) ; $ view -> setLogger ( $ logger ) ; $ view -> log ( "Rehydrated" , LogLevel :: DEBUG ) ; r...
Use this to unserialise ViewComponents
3,374
protected function getRootComponent ( ) { $ cur = $ this ; while ( $ cur -> parent !== null ) { $ cur = $ cur -> parent ; } return $ cur ; }
Get the root component of the hierarchy
3,375
protected function getPath ( ) { if ( null === $ this -> parent ) { return null ; } if ( null !== ( $ pPath = $ this -> parent -> getPath ( ) ) ) { return $ pPath . '.' . $ this -> handle ; } else { return $ this -> handle ; } }
Return the this object s path in the current component hierarchy
3,376
protected function addOrUpdateChild ( $ handle , $ type , array $ props = [ ] ) { $ this -> log ( "Adding/updating child '{$handle}' of type {$type}" , LogLevel :: DEBUG ) ; if ( ! isset ( $ this -> childComponents [ $ handle ] ) ) { if ( ! class_exists ( $ type ) ) { throw new \ Exception ( "Class '{$type}' for sub-co...
Can create a child component on this component and return it .
3,377
public function renderChild ( $ handle ) { if ( ! $ this -> childComponents [ $ handle ] ) { $ message = "Attempted to render nonexistent child component with handle '{$handle}'" ; $ this -> log ( $ message , LogLevel :: CRITICAL ) ; throw new \ Exception ( $ message ) ; } return $ this -> childComponents [ $ handle ] ...
Render a child component .
3,378
public function buildAcl ( ) { if ( $ this -> builded ) { return $ this ; } $ config = $ this -> getConfig ( ) ; $ this -> buildCommonRoles ( ) -> deny ( self :: ROLE_PUBLIC ) ; foreach ( $ config [ 'controller' ] as $ controller => $ roles ) { $ this -> addResource ( $ controller ) ; $ this -> allows ( $ roles , $ con...
Build acl if needed
3,379
public function isAllowed ( $ role = null , $ resource = null , $ privilege = null ) { $ this -> buildAcl ( ) ; return ( bool ) parent :: isAllowed ( $ role , $ resource , $ privilege ) ; }
Returns true if and only if the Role has access to the Resource
3,380
public function hasResourceParams ( $ controller , $ action = null ) { $ this -> buildAcl ( ) ; $ resource = $ this -> buildResource ( $ controller , $ action ) ; return parent :: hasResource ( $ resource ) ; }
Does the resource exists?
3,381
public function hasErrors ( $ attribute = null ) : bool { $ errors = $ this -> getErrors ( ) ; return $ attribute === null ? ! empty ( $ errors ) : isset ( $ errors [ $ attribute ] ) ; }
Identify whether there are any errors
3,382
public function getErrors ( $ attribute = null ) : array { if ( $ attribute === null ) { return $ this -> errors === null ? [ ] : $ this -> errors ; } else { return isset ( $ this -> errors [ $ attribute ] ) ? $ this -> errors [ $ attribute ] : [ ] ; } }
Returns the errors for all attribute or a single attribute .
3,383
public function getFirstError ( $ attribute ) { $ errors = $ this -> getErrors ( ) ; return isset ( $ errors [ $ attribute ] ) ? reset ( $ errors [ $ attribute ] ) : null ; }
Returns the first error of the specified attribute .
3,384
public function clearErrors ( $ attribute = null ) { if ( $ attribute === null ) { $ this -> errors = [ ] ; } else { unset ( $ this -> errors [ $ attribute ] ) ; } }
Removes errors for all attributes or a single attribute .
3,385
public function hasExecutableActivities ( Campaign $ campaign ) { $ activities = $ this -> em -> getRepository ( 'CampaignChainCoreBundle:Activity' ) -> findBy ( array ( 'campaign' => $ campaign , 'mustValidate' => true ) ) ; if ( count ( $ activities ) ) { foreach ( $ activities as $ activity ) { $ isExecutable = $ th...
Checks whether the Activities belonging to a Campaign and marked with mustValidate are executable .
3,386
public static function sanitizeIDs ( $ ids ) { if ( ! is_array ( $ ids ) ) { $ return_string = true ; $ ids = explode ( ',' , $ ids ) ; } if ( ! Arr :: iterable ( $ ids ) ) { return false ; } $ ids = array_map ( 'trim' , $ ids ) ; $ ids = array_filter ( $ ids , 'strlen' ) ; $ ids = array_map ( 'intval' , $ ids ) ; $ id...
Sanitize a list of numeric IDs and return the same format
3,387
public function parse ( $ string ) { $ hashModes = [ ] ; foreach ( $ this -> hashLibrary as $ hash ) { if ( preg_match ( '/' . $ hash [ 'regex' ] . '/i' , $ string ) ) { foreach ( $ hash [ 'modes' ] as $ mode ) { $ hashModes [ ] = new HashMode ( [ 'name' => $ mode [ 'name' ] , 'hashcat' => $ mode [ 'hashcat' ] , 'john'...
Parse the string
3,388
public function activate ( Puli $ puli ) { $ this -> puli = $ puli ; $ puli -> getEventDispatcher ( ) -> addListener ( ConsoleEvents :: CONFIG , array ( $ this , 'handleConfigEvent' ) ) ; $ puli -> getEventDispatcher ( ) -> addListener ( PuliEvents :: GENERATE_FACTORY , array ( $ this , 'handleGenerateFactoryEvent' ) )...
Activates the plugin .
3,389
public function getInstallTargetManager ( ) { if ( ! $ this -> installTargetManager ) { $ this -> installTargetManager = new PackageFileInstallTargetManager ( $ this -> getPuli ( ) -> getRootPackageFileManager ( ) , $ this -> getInstallerManager ( ) ) ; } return $ this -> installTargetManager ; }
Returns the install target manager .
3,390
public static function boot ( ICms $ cms ) { $ cms -> getLang ( ) -> addResourceDirectory ( 'package.analytics' , __DIR__ . '/../resources/lang/' ) ; $ cms -> getIocContainer ( ) -> bind ( IIocContainer :: SCOPE_SINGLETON , IAnalyticsDriverConfigRepository :: class , DbAnalyticsDriverConfigRepository :: class ) ; }
Boots the package
3,391
public static function cleanForOrder ( string $ str ) : string { $ str = self :: removeAccents ( $ str ) ; $ str = preg_replace ( "/^[^a-z0-9 ]/i" , "" , $ str ) ; $ str = trim ( $ str ) ; return $ str ; }
Clean for usort callback
3,392
public static function cleanTextarea ( $ str ) { $ str = str_replace ( '&nbsp;' , ' ' , $ str ) ; $ str = preg_replace ( "/[\r\n]{2,}/" , "\n\n" , $ str ) ; $ str = preg_replace ( "/<br([^>]*)>/" , "\n" , $ str ) ; if ( ! preg_match ( "/<(p|table|figure|div|h[1-6])>.+<\/$1>/" , $ str ) ) { $ str = '<p>' . $ str . '</p>...
Clean textarea field content
3,393
public static function toCamelCase ( $ str ) { $ str = self :: toSpaceSeparated ( $ str ) ; $ str = ucwords ( $ str ) ; $ str = str_ireplace ( ' ' , '' , $ str ) ; return $ str ; }
Convert a string into camel case .
3,394
public static function toVariable ( $ str ) { $ str = self :: toSpaceSeparated ( $ str ) ; $ str = self :: toCamelCase ( $ str ) ; $ str = preg_replace ( '#^[0-9]+.*$#' , '' , $ str ) ; $ first = substr ( $ str , 0 , 1 ) ; $ first = mb_strtolower ( $ first ) ; $ str = substr_replace ( $ str , $ first , 0 , 1 ) ; return...
Convert a string into variable form .
3,395
public static function toKey ( $ str ) { $ str = self :: toUnderscoreSeparated ( $ str ) ; $ str = mb_strtolower ( $ str ) ; return $ str ; }
Convert a string into key form .
3,396
public static function toRoman ( $ num ) { $ num = ( int ) $ num ; switch ( $ num ) { case 1 : $ roman = 'I' ; break ; case 2 : $ roman = 'II' ; break ; case 3 : $ roman = 'III' ; break ; case 4 : $ roman = 'IV' ; break ; case 5 : $ roman = 'V' ; break ; case 6 : $ roman = 'VI' ; break ; case 7 : $ roman = 'VII' ; brea...
Convertt number to Roman
3,397
private function createView ( $ view , $ viewFile , $ type , $ moduleDir ) { $ template = file_get_contents ( __DIR__ . DIRECTORY_SEPARATOR . "templates" . DIRECTORY_SEPARATOR . "view_" . $ type . ".tpl" ) ; $ template = str_replace ( '$VIEW' , $ view , $ template ) ; file_put_contents ( $ viewFile , $ template ) ; }
Cria o template da view .
3,398
public function setWsdl ( $ wsdl ) { if ( ! is_string ( $ wsdl ) || strlen ( trim ( $ wsdl ) ) == 0 ) throw new InvalidArgumentException ( __METHOD__ . '; Invalid wsdl given, must be a non empty string' ) ; $ this -> wsdl = $ wsdl ; }
Set the WSDL of this Client
3,399
protected function getSoapClient ( ) { if ( ! isset ( $ this -> wsdl ) ) throw new Exception ( __METHOD__ . '; No WSDL set' ) ; if ( ! ( is_null ( $ this -> client ) && $ this -> client instanceof SoapClient ) ) $ this -> client = new SoapClient ( $ this -> wsdl ) ; return $ this -> client ; }
Get instance of SoapClient for this Client