idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
3,500 | public function getAdminEdit ( $ id = null ) { if ( $ user = Sentinel :: findById ( $ id ) ) { $ userRoles = $ user -> getRoles ( ) -> lists ( 'name' , 'id' ) -> all ( ) ; $ roles = Sentinel :: getRoleRepository ( ) -> all ( ) ; } else { $ error = Lang :: get ( 'base.auth.not_found' ) ; return Redirect :: route ( 'user... | User update . |
3,501 | public function getAdminModalRemoveGroup ( $ id = null , $ gid = null ) { $ confirm_route = $ error = null ; $ title = 'Remove group' ; $ message = 'Are you sure to remove this group from this user?' ; $ user = Sentinel :: findById ( $ id ) ; if ( $ user == null ) { $ error = Lang :: get ( 'base.auth.not_found' ) ; ret... | Remove group Confirm |
3,502 | public function getAdminRemoveGroup ( $ id = null , $ gid = null ) { $ user = Sentinel :: findById ( $ id ) ; if ( $ user == null ) { $ error = Lang :: get ( 'base.auth.not_found' ) ; return View ( 'layouts.modal_confirmation' , compact ( 'title' , 'message' , 'error' , 'model' , 'confirm_route' ) ) ; } if ( $ user -> ... | Remove the group from the given user . |
3,503 | public function postAdminAddGroup ( $ id = null ) { $ user = Sentinel :: findById ( $ id ) ; if ( $ user == null ) { $ error = Lang :: get ( 'base.auth.not_found' ) ; return View ( 'layouts.modal_confirmation' , compact ( 'title' , 'message' , 'error' , 'model' , 'confirm_route' ) ) ; } $ gid = Input :: get ( 'group' )... | Add the group to a given user . |
3,504 | protected static function parseRss ( \ SimpleXMLElement $ xml ) { if ( isset ( $ xml -> item ) ) { $ items = $ xml -> item ; } elseif ( isset ( $ xml -> channel ) ) { $ items = $ xml -> channel -> item ; } else { return false ; } return [ 'url' => ( string ) $ xml -> channel -> link , 'items' => self :: getRssItems ( $... | Search data from Rss |
3,505 | protected static function getRssItems ( \ SimpleXMLElement $ items ) { $ rssItems = [ ] ; $ namespaces = $ items -> getNamespaces ( true ) ; foreach ( $ items as $ item ) { $ rssItem = [ 'url' => null , 'originUrl' => null , 'pubdate' => null , ] ; $ rssItem [ 'url' ] = ( string ) $ item -> link ; $ rssItem [ 'originUr... | Search items from XML |
3,506 | protected static function parseAtom ( \ SimpleXMLElement $ xml ) { if ( ! isset ( $ xml -> entry ) ) { return false ; } $ url = '' ; foreach ( $ xml -> link as $ link ) { $ attributes = $ link -> attributes ( ) ; if ( empty ( $ attributes -> href ) || ( ( string ) $ attributes -> rel === 'self' ) ) { continue ; } $ url... | Search data from Atom xml |
3,507 | protected static function getAtomEntries ( \ SimpleXMLElement $ entries ) { $ items = [ ] ; foreach ( $ entries as $ entry ) { $ item = [ 'url' => null , 'originUrl' => null , 'pubdate' => null , ] ; if ( $ entry -> created ) { $ item [ 'pubdate' ] = ( string ) $ entry -> created ; } elseif ( $ entry -> updated ) { $ i... | Search entries from Atom xml |
3,508 | protected function SelectByRole ( $ Parameters ) { if ( ! is_array ( $ Parameters ) ) { $ RoleID = $ Parameters ; } else { $ RoleID = GetValue ( 'RoleID' , $ Parameters , NULL ) ; } if ( is_string ( $ RoleID ) ) { $ RoleModel = new RoleModel ( ) ; $ Roles = explode ( ',' , $ RoleID ) ; $ RoleID = array ( ) ; foreach ( ... | Select content based on author RoleID |
3,509 | protected function SelectByRank ( $ Parameters ) { $ RankID = GetValue ( 'RankID' , $ Parameters , NULL ) ; if ( ! $ RankID ) return FALSE ; $ SelectorRankCacheKey = "modules.promotedcontent.rank.{$RankID}" ; $ Content = Gdn :: Cache ( ) -> Get ( $ SelectorRankCacheKey ) ; if ( $ Content == Gdn_Cache :: CACHEOP_FAILURE... | Select content based on author RankID |
3,510 | protected function SelectByCategory ( $ CategoryID ) { $ CategoryID = GetValue ( 'CategoryID' , $ Parameters , NULL ) ; if ( ! $ CategoryID ) return FALSE ; $ SelectorCategoryCacheKey = "modules.promotedcontent.category.{$CategoryID}" ; $ Content = Gdn :: Cache ( ) -> Get ( $ SelectorCategoryCacheKey ) ; if ( $ Content... | Select content based on its CategoryID |
3,511 | protected function SelectByScore ( $ Parameters ) { if ( ! is_array ( $ Parameters ) ) { $ MinScore = $ Parameters ; } else { $ MinScore = GetValue ( 'Score' , $ Parameters , NULL ) ; } if ( ! is_integer ( $ MinScore ) ) $ MinScore = FALSE ; $ SelectorScoreCacheKey = "modules.promotedcontent.score.{$Score}" ; $ Content... | Select content based on its Score |
3,512 | protected function JoinCategory ( & $ Comments ) { $ DiscussionIDs = array ( ) ; foreach ( $ Comments as & $ Comment ) $ DiscussionIDs [ $ Comment [ 'DiscussionID' ] ] = TRUE ; $ DiscussionIDs = array_keys ( $ DiscussionIDs ) ; $ Discussions = Gdn :: SQL ( ) -> Select ( 'd.*' ) -> From ( 'Discussion d' ) -> WhereIn ( '... | Attach CategoryID to Comments |
3,513 | protected function Union ( $ Field , $ Sections ) { if ( ! is_array ( $ Sections ) ) return ; $ Interleaved = array ( ) ; foreach ( $ Sections as $ SectionType => $ Section ) { if ( ! is_array ( $ Section ) ) continue ; foreach ( $ Section as $ Item ) { $ ItemField = GetValue ( $ Field , $ Item ) ; $ Interleaved [ $ It... | Interleave two or more result arrays by a common field |
3,514 | protected function Prepare ( & $ Content ) { foreach ( $ Content as & $ ContentItem ) { $ ContentType = GetValue ( 'ItemType' , $ ContentItem ) ; $ Replacement = array ( ) ; $ Fields = array ( 'DiscussionID' , 'CategoryID' , 'DateInserted' , 'DateUpdated' , 'InsertUserID' , 'Body' , 'Format' , 'ItemType' ) ; switch ( s... | Pre - process content into a uniform format for output |
3,515 | public function getMethod ( $ classname , $ method ) { return $ this -> hasMethod ( $ classname , $ method ) ? $ this -> methods [ $ classname . '::' . $ method ] : [ ] ; } | Retrieve class method annotations |
3,516 | public function getProperty ( $ classname , $ property ) { return $ this -> hasProperty ( $ classname , $ property ) ? $ this -> properties [ $ classname . '$' . $ property ] : [ ] ; } | Retrieve class property annotations |
3,517 | public static function getNextPermutation ( $ number ) { $ length = strlen ( $ number ) ; $ pieces = str_split ( $ number ) ; $ i = $ length - 1 ; while ( $ i > 0 && $ pieces [ $ i - 1 ] >= $ pieces [ $ i ] ) { $ i -- ; } if ( $ i <= 0 ) { return FALSE ; } $ j = $ length - 1 ; while ( $ pieces [ $ j ] <= $ pieces [ $ i... | Gets the next lexographical permutation for the given number . |
3,518 | public static function getAllPermutations ( $ number ) { $ permutations = [ ] ; $ permutation = static :: getFirstPermutation ( $ number ) ; $ permutations [ ] = $ permutation ; while ( $ permutation = static :: getNextPermutation ( $ permutation ) ) { $ permutations [ ] = $ permutation ; } return $ permutations ; } | Gets all lexographical permutations for the given number . |
3,519 | public function render ( array $ values , bool $ debug = false ) { $ vals = $ this -> compileValues ( $ values ) ; return str_replace ( array_keys ( $ vals ) , array_values ( $ vals ) , $ this -> templateSource ) ; } | Render with specified values |
3,520 | protected function compileValues ( array $ values , $ prefix = '' ) { $ retVal = [ ] ; foreach ( $ values as $ key => $ value ) { if ( is_array ( $ value ) ) { $ retVal = array_merge ( $ retVal , $ this -> compileValues ( $ value , $ prefix . $ key . '.' ) ) ; } else { $ retVal [ '{{' . $ prefix . $ key . '}}' ] = $ va... | Prepare the value array for the replacement process |
3,521 | public function save ( $ contents ) { $ file = $ this -> file ; $ return = parent :: save ( $ contents ) ; if ( $ file == $ this -> file and $ return and static :: $ flush_needed ) { if ( $ this -> file [ 0 ] !== '/' and ( ! isset ( $ this -> file [ 1 ] ) or $ this -> file [ 1 ] !== ':' ) ) { $ file = \ Finder :: searc... | Formats the output and saved it to disk . |
3,522 | protected function notifySuccess ( $ message , $ title = null , array $ options = [ ] ) { $ this -> notifyFlash ( $ message , 'success' , $ title , $ options ) ; } | Notify a success alert . |
3,523 | protected function notifyDanger ( $ message , $ title = null , array $ options = [ ] ) { $ this -> notifyFlash ( $ message , 'danger' , $ title , $ options ) ; } | Notify a danger alert . |
3,524 | protected function notifyWarning ( $ message , $ title = null , array $ options = [ ] ) { $ this -> notifyFlash ( $ message , 'warning' , $ title , $ options ) ; } | Notify a warning alert . |
3,525 | protected function notifyInfo ( $ message , $ title = null , array $ options = [ ] ) { $ this -> notifyFlash ( $ message , 'info' , $ title , $ options ) ; } | Notify an info alert . |
3,526 | protected function notifyFlash ( $ message , $ type , $ title = null , array $ options = [ ] ) { $ this -> notify ( ) -> flash ( $ message , $ type , array_merge ( $ options , compact ( 'title' ) ) ) ; } | Notify a flash alert . |
3,527 | public static function run ( $ model , $ field , $ validations ) { foreach ( $ validations as $ validation => $ options ) { if ( is_numeric ( $ validation ) ) { $ validation = $ options ; } if ( $ data = call_user_func_array ( array ( get_called_class ( ) , $ validation ) , array ( $ model , $ field , $ options ) ) and... | Runs the validations for passed Model and field . |
3,528 | public function commit ( ) { if ( $ this -> disabled ) { return ; } foreach ( $ this -> activePublishers as $ key => $ publisher ) { $ publisher -> publish ( ) ; } $ this -> activePublishers = [ ] ; } | Push all entities on remote and reset publishers |
3,529 | public function useConnection ( \ AMQPConnection $ connection ) { $ this -> settings -> set ( RabbitMqKnownSettingsEnum :: CONNECTION , $ connection ) ; return $ this ; } | Instead of the connection credentials one can use an already set up connection object . |
3,530 | public function open ( $ options = [ ] ) { if ( is_string ( $ options ) ) { $ options = [ 'class' => $ options ] ; } $ open = new Open ( $ this -> expression ( 'open' ) , $ options , $ this -> csrf , $ this ) ; return $ open ; } | create a new form |
3,531 | public function input ( $ options = [ ] ) { if ( is_string ( $ options ) ) { $ options = [ 'class' => $ options ] ; } $ input = new Input ( $ this -> expression ( 'input' ) , $ options ) ; return $ input ; } | add a new input |
3,532 | public function submit ( $ options = [ ] ) { if ( is_string ( $ options ) ) { $ options = [ 'value' => $ options ] ; } if ( ! Arr :: has ( $ options , 'type' ) ) { Arr :: set ( $ options , 'type' , 'submit' ) ; } $ input = new Input ( $ this -> expression ( 'input' ) , $ options ) ; return $ input ; } | add a new submit button |
3,533 | public function checkbox ( $ options ) { if ( is_string ( $ options ) ) { $ options = [ 'class' => $ options ] ; } if ( ! Arr :: has ( $ options , 'type' ) ) { Arr :: set ( $ options , 'type' , 'checkbox' ) ; } return $ this -> input ( $ options ) ; } | create a new checkbox input |
3,534 | public function date ( $ options = [ ] ) { if ( is_string ( $ options ) ) { $ options = [ 'class' => $ options ] ; } if ( ! Arr :: has ( $ options , 'type' ) ) { Arr :: set ( $ options , 'type' , 'date' ) ; } return $ this -> input ( $ options ) ; } | create a date input |
3,535 | public function radio ( $ options = [ ] ) { if ( is_string ( $ options ) ) { $ options = [ 'class' => $ options ] ; } elseif ( is_bool ( $ options ) ) { $ options = [ 'checked' => 'checked' ] ; } if ( ! Arr :: has ( $ options , 'type' ) ) { Arr :: set ( $ options , 'type' , 'radio' ) ; } return $ this -> input ( $ opti... | create a new radio input |
3,536 | public function getHelper ( $ name ) { if ( ! $ this -> hasHelper ( $ name ) ) { throw new Exceptions \ HelperNotFound ( $ name ) ; } if ( ! isset ( $ this -> helpers [ $ name ] ) ) { $ factory = $ this -> helperMap [ $ name ] ; $ this -> helpers [ $ name ] = $ factory ( ) ; } return $ this -> helpers [ $ name ] ; } | Returns a helper object instance using the map to factory it if needed . |
3,537 | public function init ( ) { if ( ! file_exists ( substr ( $ this -> dir , 0 , - 1 ) ) && is_writable ( dirname ( $ this -> dir ) ) ) { mkdir ( $ this -> dir , 0777 ) ; } elseif ( ! is_dir ( $ this -> dir ) ) { throw new \ Exception ( "'$this->dir' is not a directory" ) ; } elseif ( ! is_writable ( $ this -> dir ) ) { th... | Ensure the temporary directory exists and is writable . |
3,538 | public function createDirectory ( $ directory ) { $ this -> init ( ) ; $ path = $ this -> dir . $ directory ; if ( ! file_exists ( $ path ) ) { mkdir ( $ path , 0777 , true ) ; } return $ this ; } | Create a new directory in the temporary directory . Sub - directories will be created automatically if they don t exist . |
3,539 | public function getFileObject ( $ file , $ mode = 'r' ) { $ filepath = $ this -> dir . $ file ; if ( ! file_exists ( $ filepath ) || ! is_writable ( $ filepath ) ) { throw new \ Exception ( "File not found: '$file'" ) ; } return new SplFileObject ( $ filepath , $ mode ) ; } | Get an instance of SplFileObject for a file . |
3,540 | public function isEmpty ( $ directory = null ) { if ( ! $ this -> exists ( $ directory ) ) { return true ; } $ i = new FilesystemIterator ( $ this -> dir . $ directory ) ; return ! $ i -> valid ( ) ; } | Check if a temporary directory is empty . |
3,541 | public final function addCommand ( ehough_chaingang_api_Command $ command ) { if ( $ this -> _frozen ) { throw new ehough_chaingang_api_exception_IllegalStateException ( 'Chain is frozen.' ) ; } array_push ( $ this -> _commands , $ command ) ; } | Add a command to this chain . |
3,542 | protected function simpleCrypt ( $ text , $ cols = 100 ) { $ debug = Config :: getInstance ( ) -> get ( 'debug' ) ; if ( $ debug ) { return $ text ; } $ text = utf8_decode ( $ text ) ; $ key = rand ( 0 , 255 ) ; $ output = strtoupper ( sprintf ( '%02s' , dechex ( 255 - $ key ) ) ) ; $ i = 0 ; while ( isset ( $ text { $... | Code text by printing all ascii codes . |
3,543 | public function addUser ( $ username , $ password , array $ roles ) { $ this -> userProvider -> createUser ( new User ( $ username , $ password , $ roles ) ) ; } | Add a new user to the list of hard - coded users . |
3,544 | static function arrayEqual ( $ expected , $ actual ) { if ( ! self :: isArrayEqual ( $ expected , $ actual ) ) { NAssert :: fail ( '%1 should be equal (without considering key order) to %2' , $ actual , $ expected ) ; } } | Assert array equality without considering key order and without strict comparision . |
3,545 | static function arraySame ( $ expected , $ actual ) { if ( ! self :: isArraySame ( $ expected , $ actual ) ) { NAssert :: fail ( '%1 should be same (without considering key order) to %2' , $ actual , $ expected ) ; } } | Assert array equality without considering key order and with strict comparision |
3,546 | public static function Fad03 ( $ t ) { $ a ; $ a = fmod ( 1072260.703692 + $ t * ( 1602961601.2090 + $ t * ( - 6.3706 + $ t * ( 0.006593 + $ t * ( - 0.00003169 ) ) ) ) , TURNAS ) * DAS2R ; return $ a ; } | - - - - - - - - - i a u F a d 0 3 - - - - - - - - - |
3,547 | public function count ( ) { if ( $ this -> counterOwner instanceof ParamsHolder ) { return $ this -> counterOwner -> params [ $ this -> counterParam ] ; } else { return ArrayHelper :: getValue ( $ this -> counterOwner , $ this -> counterParam , 0 ) ; } } | Return count of owner entity instances within current application |
3,548 | public static function getOutbox ( $ all = false ) { global $ PPHP ; $ db = $ PPHP [ 'db' ] ; $ q = $ db -> query ( "SELECT *, datetime(modified, 'localtime') AS localmodified FROM emails" ) ; $ q -> where ( 'NOT isSent' ) ; if ( ! $ all ) { $ q -> and ( 'sender = ?' , $ _SESSION [ 'user' ] [ 'id' ] ) ; } ; $ outbox = ... | Get outbox e - mails oldest first |
3,549 | public static function getOutboxEmail ( $ id ) { global $ PPHP ; $ db = $ PPHP [ 'db' ] ; $ q = $ db -> query ( "SELECT *, datetime(modified, 'localtime') AS localmodified FROM emails" ) ; $ q -> where ( 'id = ?' , $ id ) ; $ email = $ db -> selectSingleArray ( $ q ) ; if ( $ email !== false ) { foreach ( array ( 'reci... | Fetch a single e - mail from user s outbox |
3,550 | public static function deleteOutboxEmail ( $ id ) { global $ PPHP ; $ db = $ PPHP [ 'db' ] ; $ q = $ db -> query ( 'DELETE FROM emails WHERE id=?' , $ id ) ; if ( ! pass ( 'has_role' , 'admin' ) ) { $ q -> and ( 'sender=?' , $ _SESSION [ 'user' ] [ 'id' ] ) ; } ; $ res = $ db -> exec ( $ q ) ; if ( $ res !== false ) { ... | Delete an e - mail from outbox |
3,551 | public static function sendOutboxEmail ( $ id , $ tampered = true ) { global $ PPHP ; $ db = $ PPHP [ 'db' ] ; $ mailfrom = null ; $ cc = null ; $ bcc = null ; if ( ! $ id ) { return false ; } ; $ email = self :: getOutboxEmail ( $ id ) ; if ( ! $ email ) { return false ; } ; if ( $ email [ 'mailfrom' ] ) { $ mailfrom ... | Send an e - mail from the user s outbox |
3,552 | private static function _sendmail ( $ mailfrom , $ to , $ cc , $ bcc , $ subject , $ html , $ files = array ( ) ) { global $ PPHP ; $ msg = new \ Email ( ) ; $ msg -> X_Mailer_Info = 'PyritePHP v1.0' ; $ msg -> to = $ to ; if ( $ cc && $ cc !== '' ) { $ msg -> cc = $ cc ; } ; if ( $ bcc && $ bcc !== '' ) { $ msg -> bcc... | Actually send an e - mail |
3,553 | public static function send ( $ to , $ cc , $ bcc , $ template , $ args = array ( ) , $ files = array ( ) , $ nodelay = false ) { global $ PPHP ; $ blocks = grab ( 'render_blocks' , 'email/' . $ template , $ args ) ; if ( ! is_array ( $ to ) ) { $ to = array ( $ to ) ; } ; if ( $ cc !== null && ! is_array ( $ cc ) ) { ... | Send e - mail |
3,554 | public static function mailq ( ) { global $ PPHP ; $ db = $ PPHP [ 'db' ] ; $ q = $ db -> query ( "SELECT id FROM emails" ) ; $ q -> where ( 'NOT isSent' ) ; $ q -> and ( 'sender = ?' , 0 ) ; $ q -> and ( "modified < datetime('now', '-1 hour')" ) ; $ queue = $ db -> selectList ( $ q ) ; foreach ( $ queue as $ emailId )... | Mail queue run |
3,555 | public function reverse ( ) { $ entities = new Entities ( ) ; foreach ( array_reverse ( $ this -> _entities ) as $ entity ) { $ entities -> add ( $ entity ) ; } return $ entities ; } | reverse sorted . |
3,556 | public function getByPosition ( $ position ) { return isset ( $ this -> _entities [ $ position ] ) ? $ this -> _entities [ $ position ] : null ; } | get by position . |
3,557 | protected function extractNextDataString ( $ data , $ lastPosition ) { $ substring = substr ( $ data , $ lastPosition ) ; $ reader = new BinnReader ( ) ; $ container = $ reader -> readNext ( $ substring ) ; $ substring = $ container -> getByteString ( ) ; $ substringLength = strlen ( $ substring ) ; $ nextIndex = $ las... | Reads a It is assumed that the lastPosition points to the first byte of a type definition . |
3,558 | public static function replaceTablePrefix ( $ sql , $ filter = [ ] ) { $ parser = new PHPSQLParser ( ) ; $ parsed = $ parser -> parse ( $ sql , false ) ; $ tableNames = [ ] ; if ( isset ( $ parsed [ 'FROM' ] ) ) { foreach ( $ parsed [ 'FROM' ] as $ table ) { if ( $ table [ 'expr_type' ] == 'table' ) { $ tableNames [ ] ... | Help developers to migrate using native SQL constructs to support IDE . |
3,559 | private function setSaltFromParams ( array $ params ) { $ salt = $ this -> getMatchingData ( $ params , '/^[\.\\A-Za-z0-9]{22}$/' ) ; $ this -> salt = ( ! empty ( $ salt ) ) ? $ salt : self :: DEFAULT_SALT ; } | Sets the salt string from parameter array . If no salt is given the default value will be used! |
3,560 | private function setCostFromParams ( array $ params ) { $ cost = ( int ) $ this -> getMatchingData ( $ params , '/^[0-9]{1,2}$/' ) ; $ this -> cost = ( ! empty ( $ cost ) ) ? ( string ) $ cost : self :: DEFAULT_COST ; } | Sets the cost string from parameter array . If no cost is given the default value will be used! |
3,561 | private function getMatchingData ( array $ params , $ regex ) { foreach ( $ params as $ data ) { if ( preg_match ( $ regex , $ data ) ) { return $ data ; } } return '' ; } | Returns the first match from parameter array |
3,562 | private function createDeleteForm ( BaseActor $ actor ) { return $ this -> createFormBuilder ( ) -> setAction ( $ this -> generateUrl ( 'core_baseactor_delete' , array ( 'id' => $ actor -> getId ( ) ) ) ) -> setMethod ( 'DELETE' ) -> getForm ( ) ; } | Creates a form to delete a Actor entity . |
3,563 | public function emailAction ( Request $ request , $ id ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ entity = $ em -> getRepository ( 'CoreBundle:BaseActor' ) -> find ( $ id ) ; $ form = $ this -> createForm ( ActorEmailType :: class , null , array ( 'email' => $ entity -> getEmail ( ) ) ) ; if ( $ request... | Creates a new Newsletter entity . |
3,564 | public function uploadProfileImage ( Request $ request , $ id ) { if ( ! $ id ) { throw $ this -> createNotFoundException ( 'Unable to upload.' ) ; } if ( $ id != $ this -> get ( 'security.token_storage' ) -> getToken ( ) -> getUser ( ) -> getId ( ) ) { throw $ this -> createNotFoundException ( 'Can not upload anything... | Upload profile image |
3,565 | public function get ( $ field ) { $ client = $ this -> getClient ( ) ; return $ client -> hget ( $ this -> getKey ( ) -> getName ( ) , $ field ) ; } | Returns hash field value |
3,566 | public function fields ( $ pattern , $ position = 0 ) { return $ this -> getClient ( ) -> hscan ( $ this -> getKey ( ) -> getName ( ) , $ position , 'MATCH' , $ pattern ) ; } | Returns fields matching given pattern |
3,567 | public function mget ( array $ fields ) { $ result = array ( ) ; foreach ( $ fields as $ field ) { $ result [ $ field ] = $ this -> get ( $ field ) ; } return $ result ; } | Multiget fields values |
3,568 | public function set ( $ field , $ value ) { $ client = $ this -> getClient ( ) ; $ client -> hset ( $ this -> getKey ( ) -> getName ( ) , $ field , $ value ) ; return true ; } | Sets field value |
3,569 | public function mset ( array $ fields , array $ values ) { if ( count ( $ fields ) !== count ( $ values ) ) { throw new \ InvalidArgumentException ( "Fields and values array have to be equal!" ) ; } $ combined = array_combine ( $ fields , $ values ) ; foreach ( $ combined as $ field => $ value ) { $ this -> set ( $ fie... | Multiset hash values |
3,570 | public function getFactory ( $ name ) { if ( isset ( $ this -> factories [ $ name ] ) ) { return $ this -> factories [ $ name ] ; } throw new SourceDataException ( sprintf ( 'Mapper source data factory %s not found!' , $ name ) ) ; } | Get mapper data factory . |
3,571 | public function create ( $ value ) { $ class = $ this -> getClassName ( ) ; $ tag = new $ class ( ) ; $ tag -> setName ( $ value ) ; $ tag -> setCode ( $ this -> urlizer -> urlize ( $ value , '_' ) ) ; $ tag -> setSlug ( $ this -> urlizer -> urlize ( $ value , '-' ) ) ; return $ tag ; } | Create an empty tag instance |
3,572 | public function add ( $ value ) { $ tag = $ this -> create ( $ value ) ; if ( null !== $ persistedTag = $ this -> findOneByCode ( $ tag -> getCode ( ) ) ) { $ tag = $ persistedTag ; } else { $ this -> save ( $ tag ) ; } return $ tag ; } | Create a tag instance if not exists otherwise return |
3,573 | public function sendActivationEmailToClient ( $ obj , array $ input ) { $ mailer = App :: make ( 'palmamailer' ) ; if ( isset ( $ input [ "activated" ] ) && $ input [ "activated" ] && ( ! $ obj -> activated ) ) { $ mailer -> sendTo ( $ obj -> email , [ "email" => $ obj -> email ] , "You are activated on " . Config :: g... | Send activation email to the client if it s getting activated |
3,574 | public function __soapCall ( $ function_name , $ arguments , $ options = null , $ input_headers = null , & $ output_headers = null ) { $ class = get_class ( $ this ) ; $ service = strtr ( substr ( $ class , strrpos ( $ class , '\\' ) + 1 ) , [ 'ServiceService' => 'Service' ] ) ; $ this -> __setCookie ( 'timestamp' , $ ... | Extended soap call that implements the TransIP request signing logic . |
3,575 | protected function createResourceOwner ( array $ response , AccessToken $ token ) { $ result = isset ( $ response [ 'result' ] ) ? $ response [ 'result' ] : [ ] ; if ( ! ( $ result instanceof AuthUserDetailsResponse ) ) { $ result = AuthUserDetailsResponse :: make ( $ result ) ; } $ user = new OAuthUser ( [ 'uid' => $ ... | Generates a resource owner object from a successful resource owner details request . |
3,576 | public function start ( ) { $ this -> bufferized = true ; $ newHelper = clone $ this ; $ this -> bufferized = false ; return $ newHelper ; } | Start the output buffering |
3,577 | protected function getPath ( $ path ) { $ pathsFile = __DIR__ . '/../../../../../config/rinvex.composable.php' ; $ paths = file_exists ( $ pathsFile ) ? require $ pathsFile : [ ] ; return $ paths [ $ path ] ?? __DIR__ . $ this -> paths [ $ path ] ; } | Return the path . |
3,578 | public static function inProperty ( string $ name , DeserializesCollections $ collection , Deserializes $ item ) : ExposesDataKey { return new self ( $ name , $ name , $ collection , $ item ) ; } | Creates a new nested has - many mapping . |
3,579 | public static function inPropertyWithDifferentKey ( string $ name , string $ key , DeserializesCollections $ collection , Deserializes $ item ) : ExposesDataKey { return new self ( $ name , $ key , $ collection , $ item ) ; } | Creates a new nested has - many mapping using the data from a specific key . |
3,580 | private function itemsFromArray ( array $ data ) : array { $ objects = [ ] ; foreach ( $ data [ $ this -> key ( ) ] as $ objectData ) { $ objects [ ] = $ this -> item -> from ( $ objectData ) ; } return $ objects ; } | Hydrates the instances for in a collection . |
3,581 | public static function columnKeys ( $ rows ) { $ debug = \ bdk \ Debug :: getInstance ( ) ; return $ debug -> methodTable -> colKeys ( $ rows ) ; } | Go through all the rows of array to determine what the keys are and their order |
3,582 | public static function columnVals ( $ rows , $ colName ) { $ return = array ( ) ; foreach ( $ rows as $ row ) { $ return [ ] = isset ( $ row [ $ colName ] ) ? $ row [ $ colName ] : null ; } return $ return ; } | for an associative array return all the values for given column name see also uniqueCol |
3,583 | public static function implodeDelim ( $ values , $ char = ',' ) { if ( \ is_array ( $ char ) ) { list ( $ values , $ char ) = array ( $ char , $ values ) ; } if ( empty ( $ values ) ) { return '' ; } $ str = '' ; foreach ( $ values as $ k => $ v ) { if ( $ char == ',' ) { $ v = \ str_replace ( '"' , '""' , $ v ) ; } if... | Implode array ala CSV |
3,584 | public static function isHash ( $ array ) { $ hash = false ; if ( \ is_array ( $ array ) && ! empty ( $ array ) ) { $ keys = \ array_keys ( $ array ) ; foreach ( $ keys as $ k ) { if ( ! \ is_int ( $ k ) ) { $ hash = true ; break ; } } } return $ hash ; } | returns true if array is not empty and there is a non - int key |
3,585 | public static function keyRename ( & $ array , $ from , $ to ) { if ( \ is_array ( $ array ) && $ from !== $ to ) { $ keys = \ array_keys ( $ array ) ; $ pos = \ array_search ( $ from , $ keys , true ) ; if ( $ pos !== false ) { $ nextKey = isset ( $ keys [ $ pos + 1 ] ) ? $ keys [ $ pos + 1 ] : null ; $ value = $ arra... | Rename a key while maintaining position |
3,586 | public static function mapDeep ( $ function , $ aOrV , $ params = array ( ) , $ opts = array ( ) , & $ hist = array ( ) ) { $ opts = \ array_merge ( array ( 'callback_expects' => 'scalar' , 'resource' => false , 'depth' => 0 , ) , $ opts ) ; $ callbackParams = $ params ; if ( ! \ is_array ( $ callbackParams ) ) { $ cal... | Apply function to array values |
3,587 | public static function objToArray ( $ var , $ lowerCaseKeys = true ) { if ( \ is_object ( $ var ) ) { $ var = \ get_object_vars ( $ var ) ; } if ( \ is_array ( $ var ) ) { if ( $ lowerCaseKeys ) { $ var = \ array_change_key_case ( $ var ) ; } foreach ( $ var as $ k => $ v ) { $ var [ $ k ] = self :: objToArray ( $ v , ... | Convert object to array |
3,588 | public static function path ( & $ array , $ path = array ( ) , $ value = '>-null-<' ) { return $ value !== '>-null-<' ? self :: pathSet ( $ array , $ path , $ value ) : self :: pathGet ( $ array , $ path ) ; } | Get or set value of array at given path |
3,589 | public static function pathSet ( & $ array , $ path , $ value = null ) { if ( ! \ is_array ( $ path ) ) { $ path = \ array_filter ( \ preg_split ( '#[\./]#' , $ path ) , 'strlen' ) ; } $ found = true ; $ cur = & $ array ; $ path = \ array_reverse ( $ path ) ; while ( $ path ) { $ key = \ array_pop ( $ path ) ; if ( ! \... | Set array value |
3,590 | public static function searchFields ( $ array , $ values , $ opts = array ( ) ) { if ( ! \ is_array ( $ array ) ) { $ array = array ( $ array ) ; } if ( ! \ is_array ( $ opts ) ) { if ( \ is_bool ( $ opts ) ) { $ opts = array ( 'whole' => $ opts , 'case' => $ opts , ) ; } else { $ opts = array ( ) ; } } $ opts = \ arra... | Find rows containing values |
3,591 | public static function searchKey ( $ array , $ needle ) { $ return = false ; if ( ! \ is_array ( $ array ) ) { $ array = array ( ) ; } $ arrayKeys = array ( ) ; foreach ( $ array as $ k => $ v ) { if ( $ k == $ needle ) { $ return = $ v ; break ; } if ( \ is_array ( $ v ) ) { $ arrayKeys [ ] = $ k ; } } if ( $ return =... | Recursively search for key in array Priority is givent to upper levels Returns first match |
3,592 | public function get ( $ path = null ) { if ( is_null ( $ path ) ) return $ this -> _tree ; if ( ! isset ( $ this -> _nodes [ $ path ] ) ) { throw new \ Exception ( __METHOD__ . ': path "' . $ path . '" does not exist.' ) ; return ; } return $ this -> _nodes [ $ path ] ; } | Gets the tree below the passed node path . |
3,593 | public function find ( $ field , $ path ) { foreach ( $ this -> _nodes as $ node ) { if ( isset ( $ node [ $ field ] ) && $ node [ $ field ] == $ path ) return $ node ; } return null ; } | Find a specific node . |
3,594 | public function getBreadcrumb ( ) { $ breadcrumb = [ ] ; if ( ! isset ( $ this -> _nodes [ $ this -> _active_path ] ) ) { throw new \ Exception ( __METHOD__ . ': you did not set an active node so you cannot retrieve a breadcrumb.' ) ; return ; } $ actual = $ this -> _nodes [ $ this -> _active_path ] ; array_unshift ( $... | Get the tree up from currently active page to the actual page or ... the breadcrumb . |
3,595 | public function getPager ( $ total_results , $ results_per_page = 20 , $ current_page = 1 ) { $ total_pages = intval ( max ( 1 , ceil ( $ total_results / $ results_per_page ) ) ) ; $ current_page = intval ( min ( max ( 1 , $ current_page ) , $ total_pages ) ) ; $ offset_start = $ results_per_page * ( $ current_page - 1... | Returns environment variables which helps you to build a pager . |
3,596 | public static function searchRecursive ( $ needle , $ haystack , $ needleKey = "" , $ strict = false , $ path = [ ] ) { if ( ! is_array ( $ haystack ) ) { return false ; } foreach ( $ haystack as $ key => $ val ) { if ( is_array ( $ val ) && $ subPath = self :: searchRecursive ( $ needle , $ val , $ needleKey , $ stric... | Search in multidimensional array and return an array path of keys to the searched item |
3,597 | public function begin ( $ request , $ endpoint , $ method , $ reference ) { $ this -> startTimestamp = microtime ( true ) ; $ this -> lastEvent = $ this -> eventFactory -> create ( $ request , $ endpoint , $ method , $ reference ) ; return $ this -> adapter -> save ( $ this -> lastEvent ) ; } | Log the beginning of a request . |
3,598 | protected function createUriPointerMap ( UriInterface $ uri ) { $ uri = clone $ uri ; $ uri -> normalize ( ) ; $ map = array ( array ( $ uri -> toString ( ) , array ( ) ) ) ; $ fragmentPointer = $ this -> pointerFactory ( ) -> createFromUri ( $ uri ) ; if ( $ fragmentPointer -> hasAtoms ( ) ) { $ atoms = array ( ) ; $ ... | Splits a URI into a form that makes it easier to match its parents with regards to URIs that contain pointers in their fragments . |
3,599 | public function random ( $ min = false , $ max = false ) { if ( $ min === false ) { $ min = new BigInteger ( 0 ) ; } if ( $ max === false ) { $ max = new BigInteger ( 0x7FFFFFFF ) ; } $ compare = $ max -> compare ( $ min ) ; if ( ! $ compare ) { return $ this -> protectedNormalize ( $ min ) ; } elseif ( $ compare < 0 )... | Generate a random number |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.