idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
53,600 | private function Error ( $ error ) { if ( $ this -> dev ) { $ this -> log [ ] = 'Error: ' . $ error ; } $ this -> errors [ ] = $ error ; } | Set an error |
53,601 | public function getErrors ( $ str = FALSE ) { $ errors = $ this -> errors ; $ this -> resetErrors ( ) ; if ( $ str ) { return implode ( '<br />' , $ errors ) ; } else { return $ errors ; } } | Return the errors |
53,602 | public static function Output ( $ status , $ msg , $ nl = TRUE , $ email = FALSE ) { $ status = strtoupper ( $ status ) ; if ( is_array ( $ msg ) || is_object ( $ msg ) ) { $ msg = Parser :: pre ( $ msg , 0 , TRUE , FALSE ) ; } echo '[' . date ( 'Y-m-d H:i:s' ) . '][' . $ status . '] ' . $ msg . ( $ nl ? "\n" : NULL ) ... | Output a log entry |
53,603 | protected function line ( $ text ) { if ( $ this -> console ) { $ this -> console -> line ( $ text ) ; } if ( $ this -> logger ) { $ this -> logger -> line ( $ text ) ; } } | Shortcut method to line method |
53,604 | protected function info ( $ text ) { if ( $ this -> console ) { $ this -> console -> info ( $ text ) ; } if ( $ this -> logger ) { $ this -> logger -> info ( $ text ) ; } } | Shortcut method to add logging info |
53,605 | protected function comment ( $ text ) { if ( $ this -> console ) { $ this -> console -> comment ( $ text ) ; } if ( $ this -> logger ) { $ this -> logger -> comment ( $ text ) ; } } | Shortcut method to comment method |
53,606 | protected function error ( $ text ) { if ( $ this -> console ) { $ this -> console -> error ( $ text ) ; } if ( $ this -> logger ) { $ this -> logger -> error ( $ text ) ; } } | Shortcut method to add logging error |
53,607 | protected function table ( $ headers , $ rows ) { if ( $ this -> console instanceof Command ) { $ this -> console -> table ( $ headers , $ rows ) ; } } | Output a table to the console |
53,608 | protected function progressBar ( $ count ) { if ( $ this -> console ) { return $ this -> console -> getOutput ( ) -> createProgressBar ( $ count ) ; } else { return new NullProgressBar ; } } | Create a progress bar |
53,609 | protected static function mustBeStringOrScalar ( $ arg , $ arg_name = null ) { if ( ! is_scalar ( $ arg ) && ! ( is_object ( $ arg ) && method_exists ( $ arg , '__toString' ) ) ) { throw new \ InvalidArgumentException ( sprintf ( '%s must be a primitive scalar PHP type or object ' . 'having `__toString()` method' , is_... | Checks whether given value is string - like or scalar type . |
53,610 | protected static function mustBeString ( $ arg , $ arg_name = null ) { if ( ! is_string ( $ arg ) && ! ( is_object ( $ arg ) && method_exists ( $ arg , '__toString' ) ) ) { throw new \ InvalidArgumentException ( sprintf ( '%s must be a primitive string PHP type or object ' . 'having `__toString()` method' , is_null ( $... | Checks whether given value is string - like type . |
53,611 | protected static function mustBeInteger ( $ arg , $ arg_name = null ) { if ( ! is_integer ( $ arg ) && ! ( $ arg instanceof N ) ) { throw new \ InvalidArgumentException ( sprintf ( '%s must be a primitive integer PHP type or ' . 'object \Malenki\Bah\N' , is_null ( $ arg_name ) ? 'Argument' : $ arg_name ) ) ; } if ( is_... | Checks whether given value is integer - like type . |
53,612 | protected static function mustBeFloat ( $ arg , $ arg_name = null ) { if ( ! is_float ( $ arg ) && ! ( $ arg instanceof N ) ) { throw new \ InvalidArgumentException ( sprintf ( '%s must be a primitive float PHP type or ' . 'object \Malenki\Bah\N' , is_null ( $ arg_name ) ? 'Argument' : $ arg_name ) ) ; } } | Checks whether given value is float - like type . |
53,613 | protected static function mustBeDouble ( $ arg , $ arg_name = null ) { if ( ! is_double ( $ arg ) && ! ( $ arg instanceof N ) ) { throw new \ InvalidArgumentException ( sprintf ( '%s must be a primitive double PHP type or ' . 'object \Malenki\Bah\N' , is_null ( $ arg_name ) ? 'Argument' : $ arg_name ) ) ; } } | Checks whether given value is double - like type . |
53,614 | protected static function mustBeNumeric ( $ arg , $ arg_name = null ) { if ( ! is_numeric ( $ arg ) && ! ( $ arg instanceof N ) ) { throw new \ InvalidArgumentException ( sprintf ( '%s must be a primitive numeric PHP type or ' . 'object \Malenki\Bah\N' , is_null ( $ arg_name ) ? 'Argument' : $ arg_name ) ) ; } } | Checks whether given value is numeric - like type . |
53,615 | protected static function mustBeArray ( $ arg , $ arg_name = null ) { $ msg = sprintf ( '%s must be a primitive integer indexed array PHP type or ' . 'object \Malenki\Bah\A' , is_null ( $ arg_name ) ? 'Argument' : $ arg_name ) ; if ( ! is_array ( $ arg ) && ! ( $ arg instanceof A ) ) { throw new \ InvalidArgumentExcept... | Checks whether given value is an array - like type . |
53,616 | protected static function mustBeHash ( $ arg , $ arg_name = null ) { $ msg = sprintf ( '%s must be a primitive named indexed array PHP type or ' . 'object \Malenki\Bah\H' , is_null ( $ arg_name ) ? 'Argument' : $ arg_name ) ; if ( ! is_array ( $ arg ) && ! ( $ arg instanceof H ) ) { throw new \ InvalidArgumentException... | Checks whether given value is a hash - like type . |
53,617 | protected static function mustBeArrayOrHash ( $ arg , $ arg_name = null ) { $ msg = sprintf ( '%s must be a primitive named indexed array PHP type or ' . '\Malenki\Bah\A or \Malenki\Bah\H or \SplFixedArray ' . ' or \ArrayIterator' , is_null ( $ arg_name ) ? 'Argument' : $ arg_name ) ; if ( ! is_array ( $ arg ) && ! ( $... | Checks whether given value is an array - like or hash - like type . |
53,618 | protected static function mustBeCallable ( $ arg , $ arg_name = null ) { if ( ! is_callable ( $ arg ) ) { throw new \ InvalidArgumentException ( sprintf ( '%s must be callable!' , is_null ( $ arg_name ) ? 'Argument' : $ arg_name ) ) ; } } | Checks whether the given argument is callable . |
53,619 | public function view ( $ viewPath ) { if ( is_a ( $ viewPath , ViewInterface :: class ) ) { $ this -> view_path = $ viewPath ; return $ this ; } elseif ( is_string ( $ viewPath ) ) { $ this -> view_path = $ this -> findView ( $ viewPath ) ; if ( isset ( $ this -> parent ) && $ this -> view_path === false ) { return $ t... | Set current view for rendering . |
53,620 | public function createSlug ( $ data , array $ unique = array ( ) ) { $ slug = sanitize_title ( $ data ) ; $ next = 1 ; while ( in_array ( $ slug , $ unique ) ) { $ slug = sanitize_title ( $ data . ' ' . $ next ++ ) ; } return $ slug ; } | Generate a slug from the given field . |
53,621 | public function getDatabases ( ) { if ( $ this -> databases === FALSE ) { if ( isset ( \ Sonic \ Sonic :: $ resources [ 'db' ] ) ) { foreach ( \ Sonic \ Sonic :: $ resources [ 'db' ] as $ key => $ db ) { $ this -> databases [ $ key ] = $ db -> getDatabaseName ( ) ; } } } return $ this -> databases ; } | Return an array of databases |
53,622 | public function getTables ( $ db ) { if ( ! isset ( $ this -> tables [ $ db ] ) ) { $ query = $ this -> db -> query ( 'SHOW TABLES FROM ' . $ db ) ; $ query -> setFetchMode ( \ PDO :: FETCH_COLUMN , 0 ) ; $ this -> tables [ $ db ] = $ query -> fetchAll ( ) ; } return $ this -> tables [ $ db ] ; } | Return an array of database tables |
53,623 | public function getColumns ( $ db , $ table ) { if ( ! isset ( $ this -> columns [ $ db ] [ $ table ] ) ) { $ this -> columns [ $ db ] [ $ table ] = $ this -> db -> query ( 'SHOW COLUMNS FROM ' . $ db . '.' . $ table ) -> fetchAll ( \ PDO :: FETCH_NUM ) ; } return $ this -> columns [ $ db ] [ $ table ] ; } | Return an array of table columns |
53,624 | public function getRelations ( $ db , $ table ) { if ( ! isset ( $ this -> relations [ $ db ] [ $ table ] ) ) { $ this -> relations [ $ db ] [ $ table ] = array ( ) ; $ query = $ this -> db -> query ( 'SHOW CREATE TABLE ' . $ db . '.' . $ table ) ; $ sql = $ query -> fetchColumn ( 1 ) ; foreach ( explode ( "\n" , $ sql... | Return an array of foreign key constraints columns |
53,625 | public static function mergeQuery ( $ url , array $ query ) { if ( ! $ query ) { return $ url ; } $ queryString = http_build_query ( $ query ) ; $ qPos = strpos ( $ url , '?' ) ; $ hashPos = strpos ( $ url , '#' ) ; $ pos = strlen ( $ url ) ; $ hasQuery = $ qPos !== false && ( $ qPos < $ hashPos || $ hashPos === false ... | Merges the specified query into the specified URL which may or may not already contain a query component . |
53,626 | protected function templateToString ( $ template , array $ data ) { $ templateFullName = $ this -> getTemplateFullName ( $ template ) ; if ( ! is_file ( $ templateFullName ) ) { throw new RuntimeException ( "View cannot render `$template` because the template does not exist" ) ; } $ fullData = array_merge ( $ this -> a... | Retourne le rendu du template sous forme de chaine |
53,627 | public function setEmail ( $ email ) { $ this -> email = $ email ; $ this -> referenceId = null ; $ this -> executed = false ; return $ this ; } | Sets email of the user |
53,628 | public function setReferenceId ( $ referenceId ) { $ this -> referenceId = $ referenceId ; $ this -> email = null ; $ this -> executed = false ; return $ this ; } | Sets reference ID for deletion |
53,629 | public static function createInstance ( $ driver , $ options , $ prefix = '' ) { if ( ! in_array ( $ driver , self :: $ _validDrivers ) ) { throw new \ Exception ( "Driver '{$driver}' not implemented" ) ; } $ class = __NAMESPACE__ . '\\Driver\\' . $ driver ; $ driver = new $ class ; $ driver -> setOptions ( $ options )... | Create new instance of G4 \ Mcache \ Mcache |
53,630 | public function setInherited ( $ inherited ) { $ this -> inherited = ( bool ) $ inherited ; if ( $ inherited ) { if ( ! $ this -> reflectionModel -> isRoot ( ) ) { $ rootRepo = Container :: get ( $ this -> reflectionModel -> getRoot ( ) -> getName ( ) ) ; $ this -> rootConfig = $ rootRepo -> getConfig ( ) ; } $ this ->... | Enables Repo inheritance allowing multiple repos to share one storage table You will need to call setRootRepo on all the child repos . |
53,631 | public function assertModel ( AbstractModel $ model ) { if ( ! $ this -> isModel ( $ model ) ) { throw new InvalidArgumentException ( sprintf ( 'Model must be instance of %s, but was %s' , $ this -> getRootConfig ( ) -> getModelClass ( ) , get_class ( $ model ) ) ) ; } } | Check if a model belongs to this repo . Child classes are also accepted |
53,632 | public function addHost ( Host $ host ) { if ( empty ( $ host ) ) return $ this ; $ this -> _host_list [ "{$host->name}:{$host->port}" ] = $ host ; return $ this ; } | adds a host to the hostlist |
53,633 | public function checkSocket ( $ socket ) { $ read = [ $ socket ] ; if ( count ( $ this -> client ) > 0 ) { for ( $ i = 0 ; $ i < $ this -> max_clients ; $ i ++ ) { if ( isset ( $ this -> client [ $ i ] ) && $ this -> client [ $ i ] [ 'sock' ] != null ) { $ read [ $ i + 1 ] = $ this -> client [ $ i ] [ 'sock' ] ; } } } ... | adds the socket to listening sockets |
53,634 | public function checkClient ( ) { if ( in_array ( $ this -> _socket_http , $ this -> read ) ) { for ( $ i = 0 ; $ i < $ this -> max_clients ; $ i ++ ) { if ( isset ( $ this -> client [ $ i ] ) && $ this -> client [ $ i ] [ 'sock' ] == null ) { $ this -> client [ $ i ] [ 'sock' ] = @ socket_accept ( $ this -> _socket_ht... | checks if there are clients accessing the specific port of the socket |
53,635 | public function getError ( ) { for ( $ i = 0 , $ c = count ( $ this -> read ) ; $ i < $ c ; $ i ++ ) { if ( ! $ this -> read [ $ i ] ) continue ; $ this -> error [ ] = socket_last_error ( $ this -> read [ $ i ] [ 'sock' ] ) ; } } | gets error and appends them to the error array |
53,636 | public function start ( ) { $ this -> _socket_http = socket_create ( AF_INET , SOCK_STREAM , IPPROTO_IP ) ; if ( ! $ this -> _socket_http ) { throw new Exception ( "Unable to create socket\n" ) ; } if ( ! socket_bind ( $ this -> _socket_http , self :: SERVER_IP , self :: LISTENING_PORT ) ) { throw new Exception ( 'Coul... | now we open an endless loop |
53,637 | public function execute ( ) { foreach ( $ this -> client as $ key => $ client ) { if ( ! in_array ( $ client [ 'sock' ] , $ this -> read ) ) { $ this -> close ( $ client [ 'sock' ] ) ; unset ( $ this -> client [ $ key ] ) ; } $ input = socket_read ( $ client [ 'sock' ] , 1024 ) ; if ( $ input == null ) { unset ( $ this... | here is where we handle the input and the types of input - > read and writes from the stream |
53,638 | public function init ( $ setting = array ( ) ) { if ( ! is_array ( $ setting ) || count ( $ setting ) == 0 ) return $ this ; foreach ( $ setting as $ key => $ value ) { if ( property_exists ( $ this , $ key ) ) { $ this -> $ key = ( string ) $ value ; } } return $ this ; } | initializes the server variables |
53,639 | public function format ( $ newFormat = null ) { if ( $ newFormat === null ) { return $ this -> format ; } $ this -> format = $ newFormat ; return $ this ; } | Format the date or return its format . |
53,640 | public function next ( ) { $ this -> pointerAtStart = false ; $ this -> pointerAtEnd = next ( $ this -> stream ) === false ; } | go to next char in stream |
53,641 | public function previous ( ) { $ this -> pointerAtEnd = false ; $ this -> pointerAtStart = prev ( $ this -> stream ) === false ; } | go to previous char of stream |
53,642 | public function ignoreWhitespace ( ) { ignoreWhitespace : if ( ! $ this -> isEnd ( ) && $ this -> currentAscii ( ) -> isWhiteSpace ( ) ) { $ this -> next ( ) ; goto ignoreWhitespace ; } } | ignore chars in stream while it is white space |
53,643 | public function ignoreHorizontalSpace ( ) { ignoreHorizontalSpace : if ( ! $ this -> isEnd ( ) && $ this -> currentAscii ( ) -> isHorizontalSpace ( ) ) { $ this -> next ( ) ; goto ignoreHorizontalSpace ; } } | ignore chars in stream while it is horizontal space |
53,644 | public function ignoreVerticalSpace ( ) { ignoreHorizontalSpace : if ( ! $ this -> isEnd ( ) && $ this -> currentAscii ( ) -> isVerticalSpace ( ) ) { $ this -> next ( ) ; goto ignoreHorizontalSpace ; } } | ignore chars in stream while it is vertical space |
53,645 | public static function parseURL ( array & $ args , $ leaveDefaultLocale = true ) { foreach ( self :: $ locales as $ locale ) { if ( ( $ key = array_search ( $ locale , $ args ) ) === 0 ) { self :: current ( $ locale ) ; if ( $ leaveDefaultLocale || $ locale != self :: DEF ) { unset ( $ args [ $ key ] ) ; $ args = array... | Parse URL arguments |
53,646 | public function optimize ( $ table = null ) { $ table = empty ( $ table ) ? $ this -> _tableName : $ table ; $ this -> _query ( "OPTIMIZE TABLE " . $ table ) ; return $ this ; } | Optimize table query |
53,647 | public function repair ( $ table = null ) { $ table = empty ( $ table ) ? $ this -> _tableName : $ table ; $ this -> _query ( "REPAIR TABLE " . $ table ) ; return $ this ; } | Repair table query |
53,648 | public function compile ( $ tplName , $ tplFile , $ outputtype , $ trusted , $ userModifiers = array ( ) , $ userFunctions = array ( ) ) { $ this -> _sourceFile = $ tplFile ; $ this -> outputType = $ outputtype ; $ cachefile = $ this -> config -> cachePath . dirname ( $ tplName ) . '/' . $ this -> outputType . ( $ trus... | Launch the compilation of a template . |
53,649 | public function presentPublishedDays ( ) { $ todaysDate = time ( ) ; $ postDate = strtotime ( $ this -> post_date ) ; $ diff = abs ( $ todaysDate - $ postDate ) ; $ years = floor ( $ diff / ( 365 * 60 * 60 * 24 ) ) ; $ months = floor ( ( $ diff - $ years * 365 * 60 * 60 * 24 ) / ( 30 * 60 * 60 * 24 ) ) ; $ days = floor... | Return how many day was published |
53,650 | public function presentCategories ( ) { $ args = array ( 'fields' => 'all' , 'orderby' => 'name' , 'order' => 'ASC' ) ; $ categories = wp_get_post_categories ( $ this -> ID , $ args ) ; if ( count ( $ categories ) == 0 || ! $ categories ) { return null ; } $ cats = array ( ) ; foreach ( $ categories as $ c ) { $ c -> p... | Return an array of object with the categories of the post |
53,651 | public function presentTags ( ) { $ args = array ( 'fields' => 'all' , 'orderby' => 'name' , 'order' => 'ASC' ) ; $ tags = wp_get_post_tags ( $ this -> ID , $ args ) ; if ( count ( $ tags ) == 0 || ! $ tags ) { return null ; } $ postTags = array ( ) ; foreach ( $ tags as $ t ) { $ t -> permalink = get_tag_link ( $ t ->... | Return an array of object with the tags of the post |
53,652 | public function terms ( $ taxonomy = 'post_tag' ) { $ postTerms = wp_get_post_terms ( $ this -> ID , $ taxonomy ) ; $ cats = array ( ) ; foreach ( $ postTerms as $ c ) { $ c -> permalink = get_term_link ( $ c , $ c -> taxonomy ) ; $ cats [ ] = $ c ; } return Collection :: make ( $ cats ) ; } | Return a collection of post taxonomies terms |
53,653 | public function taxonomies ( $ taxName = null ) { $ thisTax = ( $ taxName ) ? $ taxName : $ this -> categoryTax ; $ taxonomies = wp_get_object_terms ( $ this -> ID , $ thisTax ) ; if ( ! $ taxonomies || empty ( $ taxonomies ) ) { return null ; } $ tax = array ( ) ; foreach ( $ taxonomies as $ t ) { $ t -> permalink = g... | Return a collection of post taxonomies |
53,654 | public function gallery ( $ size = 'thumbnail' , $ format = 'array' , $ limit = - 1 ) { $ images = get_posts ( array ( 'post_parent' => $ this -> ID , 'post_type' => 'attachment' , 'numberposts' => $ limit , 'post_status' => null , 'post_mime_type' => 'image' , 'orderby' => 'menu_order' , 'order' => 'ASC' , ) ) ; if ( ... | Return the imagens on post gallery with certain format |
53,655 | public function author ( $ optionalPresenter = null ) { if ( $ optionalPresenter && $ optionalPresenter instanceof PresenterInterface ) { return new $ optionalPresenter ( $ this -> wpo , $ this -> isMainQuery ) ; } return new AuthorPresenter ( $ this -> wpo , $ this -> isMainQuery ) ; } | Return an instance of AuthorPresenter |
53,656 | public function meta ( $ metaKey = '' , $ single = true ) { $ meta_values = get_post_meta ( $ this -> ID , $ metaKey , $ single ) ; return $ meta_values ; } | Return the post meta |
53,657 | public function presentPostType ( ) { global $ wp_rewrite ; $ postType = get_post_type_object ( get_post_type ( $ this -> ID ) ) ; if ( ! $ postType ) { return null ; } if ( get_option ( 'permalink_structure' ) && is_array ( $ postType -> rewrite ) ) { $ slug = $ postType -> rewrite [ 'slug' ] ; if ( $ postType -> rewr... | Return the post type as object |
53,658 | public function MetaTags ( & $ tags ) { $ MetaMarkup = array ( ) ; $ owner = $ this -> owner ; $ tagTypes = array ( 'TagTitle' , 'MetaTagCharset' , 'MetaTagGenerator' , 'MetaTagDescription' , 'MetaTagRobots' , 'MetaTagResponsive' , 'MetaTagTwitter' , 'SchemaTagWebsite' , 'SchemaTagBreadcrumbs' , 'SchemaTagContactPoints... | Extension hook to change all tags |
53,659 | public function setFlash ( $ key , $ value ) { $ this -> session -> getFlashBag ( ) -> set ( $ key , $ value ) ; return $ this ; } | Set a flash message |
53,660 | public function addFlash ( $ key , $ value ) { $ this -> session -> getFlashBag ( ) -> add ( $ key , $ value ) ; return $ this ; } | Add a flash message |
53,661 | protected function renderContent ( ) { foreach ( $ this -> httpEquivs as $ name => $ content ) echo CHtml :: metaTag ( $ content , null , $ name ) ; if ( $ this -> _title !== null ) echo CHtml :: tag ( 'title' , array ( ) , is_array ( $ this -> _title ) ? implode ( $ this -> titleSeparator , $ this -> _title ) : $ this... | Renders the widget content . |
53,662 | private function getControllerMethods ( $ controller ) { if ( ! \ Sonic \ Sonic :: _classExists ( __NAMESPACE__ . '\\' . $ controller ) ) { return array ( ) ; } $ actions = array ( ) ; $ reflection = new \ ReflectionClass ( __NAMESPACE__ . '\\' . $ controller ) ; $ className = $ reflection -> getName ( ) ; foreach ( $ ... | Return controller methods using reflection |
53,663 | public function serializeBase64 ( SerializationVisitorInterface $ visitor , string $ data , array $ type ) { return $ visitor -> visitString ( base64_encode ( $ data ) , $ type ) ; } | Serializes the data to base64 . |
53,664 | public function deserializeBase64 ( DeserializationVisitorInterface $ visitor , $ base64 , array $ type ) : string { return ( string ) base64_decode ( $ visitor -> visitString ( $ base64 , $ type ) , true ) ; } | Deserializes the base64 string . |
53,665 | public function Connect ( $ dsn = FALSE , $ user = FALSE , $ pass = FALSE , $ options = FALSE ) { if ( ! $ this -> connected ) { $ this -> _dsn = $ dsn ? : $ this -> _dsn ; $ this -> _user = $ user ? : $ this -> _user ; $ this -> _pass = $ pass ? : $ this -> _pass ; $ this -> _options = $ options ? : $ this -> _options... | Connect to the database if not already done Will throw a PDOException is connection fails |
53,666 | public function setConnection ( $ dsn = FALSE , $ user = FALSE , $ pass = FALSE , $ options = FALSE ) { $ this -> _dsn = $ dsn ? : $ this -> _dsn ; $ this -> _user = $ user ? : $ this -> _user ; $ this -> _pass = $ pass ? : $ this -> _pass ; $ this -> _options = $ options ? : $ this -> _options ; } | Set connection details to the database Will throw a PDOException is connection fails |
53,667 | public static function genBindValues ( & $ query , $ arrWHERE ) { foreach ( $ arrWHERE as $ arrClause ) { if ( is_array ( $ arrClause [ 0 ] ) ) { self :: genBindValues ( $ query , $ arrClause ) ; } else { if ( is_array ( $ arrClause ) ) { if ( ! isset ( $ arrClause [ 2 ] ) || ( ! in_array ( $ arrClause [ 2 ] , array ( ... | Bind query values from where array |
53,668 | public function bindValues ( & $ query , $ params ) { foreach ( $ params as $ key => $ value ) { if ( is_array ( $ value ) ) { if ( ! $ query -> bindValue ( $ key , $ value [ 0 ] , $ value [ 1 ] ) ) { return FALSE ; } } else { if ( ! $ query -> bindValue ( $ key , $ value ) ) { return FALSE ; } } } return TRUE ; } | Bind an array of parameters to the query |
53,669 | public function genClause ( $ strName , $ mixOptions , $ strDefault = FALSE , $ strSeparator = ', ' ) { $ strClause = NULL ; if ( isset ( $ mixOptions ) && $ mixOptions ) { $ strClause = $ strName . ' ' ; if ( is_array ( $ mixOptions ) && count ( $ mixOptions ) > 0 ) { $ strClause .= implode ( $ strSeparator , $ mixOpt... | Generates a clause in an SQL statement |
53,670 | public function genQuery ( $ arrParams = array ( ) ) { $ strSQL = $ this -> genSQL ( $ arrParams ) ; $ query = $ this -> prepare ( $ strSQL ) ; if ( isset ( $ arrParams [ 'where' ] ) && is_array ( $ arrParams [ 'where' ] ) ) { $ this -> genBindValues ( $ query , $ arrParams [ 'where' ] ) ; } if ( isset ( $ arrParams [ ... | Returns a PDO query resource ready for execution |
53,671 | public function genUnionBindValues ( & $ query , $ args ) { foreach ( $ args as $ key => $ arg ) { if ( isset ( $ arg [ 'where' ] ) && is_array ( $ arg [ 'where' ] ) ) { $ this -> genBindValues ( $ query , $ arg [ 'where' ] ) ; } if ( isset ( $ arg [ 'having' ] ) && is_array ( $ arg [ 'having' ] ) ) { $ this -> genBind... | Bind values to a union query |
53,672 | public function getValue ( $ arrParams , $ fetchMode = \ PDO :: FETCH_BOTH ) { if ( ! $ this -> validateParams ( $ arrParams ) ) { return FALSE ; } $ arrParams [ 'limit' ] = '1' ; $ query = $ this -> genQuery ( $ arrParams ) ; $ query -> execute ( ) ; $ arrResult = $ query -> fetch ( $ fetchMode ) ; if ( is_array ( $ a... | Return a single value or row |
53,673 | public function getValues ( $ arrParams ) { if ( ! $ this -> validateParams ( $ arrParams ) ) { return FALSE ; } $ query = $ this -> genQuery ( $ arrParams ) ; $ query -> execute ( ) ; $ arrSelect = is_array ( $ arrParams [ 'select' ] ) ? $ arrParams [ 'select' ] : explode ( ',' , $ arrParams [ 'select' ] ) ; if ( coun... | Return all rows or array of single values |
53,674 | public function fetchAssocBySql ( $ strSQL , $ arrBindParams = array ( ) ) { $ query = $ this -> prepare ( $ strSQL ) ; if ( ! $ this -> bindValues ( $ query , $ arrBindParams ) ) { return FALSE ; } $ success = $ query -> execute ( ) ; if ( ! $ success ) { return FALSE ; } return $ query -> fetchAll ( 2 ) ; } | Get the query associate resultset with sql and bind params |
53,675 | public function addTransactionHook ( Db & $ db ) { $ dsn = $ db -> getDSN ( ) ; if ( $ dsn != $ this -> getDSN ( ) && ! isset ( $ this -> _transaction_hooks [ $ dsn ] ) ) { $ this -> _transaction_hooks [ $ dsn ] = & $ db ; return TRUE ; } return FALSE ; } | Add a transaction hook to commit and rollback another database at the same time as this database |
53,676 | public function commit ( ) { if ( -- $ this -> transactionCount === 0 ) { $ status = parent :: commit ( ) ; if ( $ this -> _transaction_hooks ) { if ( $ status ) { foreach ( $ this -> _transaction_hooks as $ dsn => & $ db ) { $ db -> commit ( ) ; } } $ this -> _transaction_hooks = array ( ) ; } return $ status ; } else... | Commits a transaction as long as there are no other active transactions |
53,677 | public function rollBack ( ) { if ( -- $ this -> transactionCount === 0 ) { $ status = parent :: rollBack ( ) ; if ( $ this -> _transaction_hooks ) { foreach ( $ this -> _transaction_hooks as & $ db ) { $ db -> rollBack ( ) ; } $ this -> _transaction_hooks = array ( ) ; } return $ status ; } else { return FALSE ; } } | Rolls back a transaction and allows new transactions to begin |
53,678 | public function hasPermission ( $ module , $ action , User $ user = null ) { $ module = $ this -> service -> getModuleManager ( ) -> load ( $ module ) ; $ action = $ module -> getActionModel ( $ action ) ; return $ this -> hasActionPermission ( $ action , $ user ) ; } | Checks the permission for the given module and action name |
53,679 | private function getPermissionTable ( User $ user ) { $ userId = $ user -> getId ( ) ; if ( $ this -> permissionTable -> has ( $ userId ) ) { return $ this -> permissionTable -> get ( $ userId ) ; } $ guestGroup = GroupQuery :: create ( ) -> findOneByIsGuest ( true ) ; $ groups = GroupQuery :: create ( ) -> filterByUse... | Returns a set of allowed action ids |
53,680 | public static function pgQueryParams ( $ sql , $ params , $ suppress = false ) { $ db_handler = DatabaseHandler :: init ( ) ; return $ db_handler -> query ( $ sql , $ params , $ suppress ) ; } | Run a PostgreSQL statement with given parameters |
53,681 | public function removeListener ( $ eventName , $ listener ) { if ( ! isset ( $ this -> listeners [ $ eventName ] ) ) { return false ; } foreach ( $ this -> listeners [ $ eventName ] as $ i => $ callback ) { if ( $ listener === $ callback ) { unset ( $ this -> listeners [ $ eventName ] [ $ i ] ) ; } } if ( count ( $ thi... | Disconnects a listener for a given event name . |
53,682 | public function dispatch ( $ eventName , Event $ event ) { if ( ! $ this -> hasListeners ( $ eventName ) ) { return $ event ; } $ event -> setName ( $ eventName ) ; foreach ( $ this -> getListeners ( $ event -> getName ( ) ) as $ listener ) { call_user_func ( $ listener , $ event ) ; if ( $ event -> isPropagationStoppe... | Dispatch all listeners of a given event . |
53,683 | public function dispatchUntil ( $ eventName , Event $ event ) { if ( $ event -> isProcessed ( ) ) { return $ event ; } if ( ! $ this -> hasListeners ( $ eventName ) ) { return $ event ; } $ event -> setName ( $ eventName ) ; foreach ( $ this -> getListeners ( $ event -> getName ( ) ) as $ listener ) { if ( call_user_fu... | Dispatch all listeners of a given event until one returns a non null value . |
53,684 | public function hasListeners ( $ eventName = '' ) { $ count = 0 ; if ( empty ( $ eventName ) ) { $ count = count ( $ this -> listeners ) ; } elseif ( isset ( $ this -> listeners [ $ eventName ] ) ) { $ count = count ( $ this -> listeners [ $ eventName ] ) ; } return ( boolean ) $ count ; } | Returns true if the given event name has some listeners . |
53,685 | public function redirect ( $ location , $ statusCode = 302 ) { $ this -> response -> setHeader ( 'Location' , $ location , true , $ statusCode ) ; return $ this ; } | Redirect user to the new url |
53,686 | public function render ( ) { $ args = func_get_args ( ) ; if ( isset ( $ args [ 0 ] ) && is_string ( $ args [ 0 ] ) ) { $ tpl = array_shift ( $ args ) ; } else { $ tpl = get_class ( $ this ) ; $ paths = explode ( '\\' , $ tpl ) ; array_shift ( $ paths ) ; $ className = array_pop ( $ paths ) ; $ actionSuffix = 'Action' ... | Render a template and returns html |
53,687 | public function getClientIp ( ) : string { $ s = $ this -> server ( ) ; if ( array_key_exists ( 'HTTP_CLIENTIP' , $ s ) ) { if ( ! empty ( $ s [ 'HTTP_CLIENTIP' ] ) ) { return $ s [ 'HTTP_CLIENTIP' ] ; } } if ( array_key_exists ( 'HTTP_X_FORWARDED_FOR' , $ s ) && ! empty ( $ s [ 'HTTP_X_FORWARDED_FOR' ] ) ) { $ address... | Gets the client side WAN ip address . |
53,688 | public function validateFile ( $ attribute , $ value ) { $ extension = $ value -> getClientOriginalExtension ( ) ; if ( $ extension !== 'csv' ) { $ this -> setCustomMessages ( [ $ attribute => trans ( 'File has invalid extension' ) ] ) ; $ this -> addFailure ( $ attribute , $ attribute , [ ] ) ; return false ; } return... | validates csv file |
53,689 | public function inferMachineType ( $ aref , & $ type , & $ id ) { $ len = count ( $ aref ) ; if ( $ len == 0 ) { return false ; } $ type = str_replace ( '-' , '_' , array_shift ( $ aref ) ) ; if ( ! isset ( $ this -> machine_type_table [ $ type ] ) ) { return false ; } switch ( $ len ) { case 1 : $ id = null ; break ; ... | Infer type of referenced machine type using lookup table . |
53,690 | protected function createListing ( Smalldb $ smalldb , $ filters , $ filtering_flags = 0 ) : IListing { $ type = $ filters [ 'type' ] ; $ machine = $ this -> getMachine ( $ smalldb , $ type ) ; if ( $ machine === null ) { throw new InvalidArgumentException ( 'Machine type "' . $ type . '" not found.' ) ; } unset ( $ fi... | Creates a listing using given filters . |
53,691 | protected function setBuildItems ( ) { $ crcy = Factory :: create ( $ this -> code ) ; $ refl = new \ ReflectionClass ( $ crcy ) ; $ fmt = $ refl -> getProperty ( 'displayFormat' ) ; $ fmt -> setAccessible ( true ) ; $ locale = $ refl -> getProperty ( 'locale' ) ; $ locale -> setAccessible ( true ) ; $ precision = $ re... | Set up the build items that this builder will manage We don t need to do any complicated build routine so can set values here |
53,692 | public function activate ( Composer $ composer , IOInterface $ io ) { $ this -> composer = $ composer ; $ this -> io = $ io ; if ( isset ( $ this -> composer -> getPackage ( ) -> getExtra ( ) [ 'auto-require' ] [ 'vendor-name' ] ) ) { $ this -> vendorName = $ this -> composer -> getPackage ( ) -> getExtra ( ) [ 'auto-r... | activate the composer plugins |
53,693 | public function autoRequirePackagesPreRequire ( PreCommandRunEvent $ event ) { if ( $ event -> getCommand ( ) == 'require' ) { $ companyPackages = [ ] ; $ commandPackages = $ event -> getInput ( ) -> getArgument ( 'packages' ) ; foreach ( $ commandPackages as $ package ) { $ companyPackages [ explode ( '=' , $ package ... | Method for the pre - command - run event |
53,694 | public function autoRequirePackagesPreUpdate ( Event $ event ) { $ companyPackages = [ ] ; $ packages = $ this -> composer -> getPackage ( ) -> getRequires ( ) ; foreach ( $ packages as $ packageName => $ package ) { if ( $ this -> startsWith ( $ packageName , $ this -> vendorName ) ) { $ companyPackages [ $ packageNam... | Method for the pre - update - cmd event |
53,695 | public function index ( ) { $ items = new $ this -> listClass ( ) ; $ this -> applyListFilters ( $ items ) ; $ items -> load ( ) ; $ this -> template -> vars [ $ this -> listTplVar ] = $ items ; if ( $ this -> pagedList ) { $ this -> template -> vars [ 'pagination' ] = [ 'page' => ( int ) ( isset ( $ _GET [ 'page' ] ) ... | Action for list entities . |
53,696 | protected function applyListFilters ( ModelCollection $ items ) { return $ this -> pagedList ? $ items -> page ( isset ( $ _GET [ 'page' ] ) ? $ _GET [ 'page' ] : 0 , $ this -> recordsPerPage ) : $ items ; } | Apply additional criteria to list query . |
53,697 | protected function prepareEditorTpl ( $ id = null ) { $ mode = $ id === null ? 'create' : 'edit' ; $ item = new $ this -> itemClass ( ) ; if ( $ _POST ) { $ this -> save ( $ id , $ item ) ; return ; } $ this -> loadTemplate ( $ mode ) ; if ( $ mode == 'edit' ) { $ item -> load ( $ id ) ; } $ this -> initItem ( $ item ,... | Prepare template for create & edit action . |
53,698 | public function input ( $ buffer , $ connection ) { if ( empty ( $ this -> seckey ) ) { $ this -> seckey = $ connection -> listener -> getHandler ( ) -> secKey ; } if ( ! $ connection -> hasAttribute ( $ this -> seckey ) ) { return $ this -> handshakeInput ( $ buffer , $ connection ) ; } return $ this -> streamInput ( ... | parse http|websocket stream request packet |
53,699 | public function handshakeInput ( $ buffer , $ connection ) { $ len = parent :: input ( $ buffer , $ connection ) ; if ( ! $ len ) return 0 ; $ req = new HttpReqeust ( ) ; $ req -> loadRequest ( $ buffer ) ; if ( $ req -> headers -> get ( 'Connection' ) !== 'Upgrade' ) { throw new \ Exception ( "Bad Connection" , 412 ) ... | http handshake process |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.