idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
5,800 | public static function model ( $ model , $ handler = null ) { $ model_data = call_user_func ( $ model . '::_model' ) ; return Query :: select ( $ model_data [ 'table' ] , null , $ model_data [ 'handler' ] ) -> fetch_handler ( $ model . '::_fetch_handler' ) ; } | Create a select query with an model assignment |
5,801 | public static function last ( $ table , $ key = null , $ handler = null ) { return Query :: select ( $ table ) -> last ( $ key , $ handler ) ; } | Get the last result by key |
5,802 | public static function insert ( $ table , $ values = array ( ) , $ handler = null ) { return Query :: insert ( $ table , $ values , $ handler ) ; } | Create an insert query object |
5,803 | public function modalInfoAction ( $ id ) { $ oCustomer = CustomerQuery :: create ( ) -> findOneById ( $ id ) ; return $ this -> render ( 'SlashworksAppBundle:Customer:modal_info.html.twig' , array ( 'customer' => $ oCustomer ) ) ; } | Modal info window for customerinformations |
5,804 | public function newAction ( ) { $ oCustomer = new Customer ( ) ; $ form = $ this -> createCreateForm ( $ oCustomer ) ; return $ this -> render ( 'SlashworksAppBundle:Customer:new.html.twig' , array ( 'entity' => $ oCustomer , 'form' => $ form -> createView ( ) , ) ) ; } | Displays a form to create a new Customer entity . |
5,805 | public function editAction ( $ id ) { $ oCustomer = CustomerQuery :: create ( ) -> findOneById ( $ id ) ; if ( count ( $ oCustomer ) === 0 ) { throw $ this -> createNotFoundException ( 'Unable to find Customer entity.' ) ; } $ oEditForm = $ this -> createEditForm ( $ oCustomer ) ; $ oDeleteForm = $ this -> createDelete... | Displays a form to edit an existing Customer entity . |
5,806 | public function updateAction ( Request $ request , $ id ) { $ oCustomer = CustomerQuery :: create ( ) -> findOneById ( $ id ) ; if ( count ( $ oCustomer ) === 0 ) { throw $ this -> createNotFoundException ( 'Unable to find Customer entity.' ) ; } $ deleteForm = $ this -> createDeleteForm ( $ id ) ; $ editForm = $ this ... | Update existing customer |
5,807 | private function _handleLogoUpload ( Request & $ request , Customer & $ oCustomer ) { $ sLogoPath = "" ; $ oFiles = $ request -> files ; $ aFiles = $ oFiles -> get ( "slashworks_appbundle_customer" ) ; $ sUploadPath = __DIR__ . "/../../../../web/files/customers" ; if ( isset ( $ aFiles [ 'logo' ] ) ) { if ( ! empty ( $... | Handle Logo uplaod |
5,808 | private function createCreateForm ( Customer $ oCustomer ) { $ form = $ this -> createForm ( new CustomerType ( array ( "language" => $ this -> get ( 'request' ) -> getLocale ( ) ) ) , $ oCustomer , array ( 'action' => $ this -> generateUrl ( 'backend_system_customer_create' ) , 'method' => 'POST' , ) ) ; $ form -> add... | Creates a form to create a Customer entity . |
5,809 | private function createEditForm ( Customer $ oCustomer ) { $ oForm = $ this -> createForm ( new CustomerType ( array ( "language" => $ this -> get ( 'request' ) -> getLocale ( ) ) ) , $ oCustomer , array ( 'action' => $ this -> generateUrl ( 'backend_system_customer_update' , array ( 'id' => $ oCustomer -> getId ( ) ) ... | Create form for editing customer |
5,810 | protected function sendMessage ( BaseMessageInterface $ message , $ baseUrl , array $ options = array ( ) ) { $ client = $ this -> createClient ( sprintf ( '%s/%s' , $ baseUrl , $ this -> flowApiToken ) ) ; $ response = $ client -> post ( null , array_merge ( $ options , [ 'headers' => [ 'Content-Type' => 'application/... | Sends a message to a flow |
5,811 | public function findFiles ( ) { $ search = ( new Finder ( ) ) -> files ( ) ; foreach ( $ this -> paths as $ path ) { if ( is_readable ( $ path ) ) { $ search -> in ( $ path ) ; } } foreach ( $ this -> files as $ pattern ) { $ search -> name ( $ pattern ) ; } $ array = array ( ) ; foreach ( $ search as $ f ) { $ array [... | Return an array of file paths to config files |
5,812 | public function hasRole ( $ role ) { if ( ! $ this -> roles -> where ( 'token' , $ role ) -> isEmpty ( ) ) { return true ; } foreach ( $ this -> groups as $ group ) { if ( ! $ group -> roles -> where ( 'token' , $ role ) -> isEmpty ( ) ) { return true ; } } return false ; } | Check if user has given role |
5,813 | public function hasPermission ( $ permission ) { if ( ! $ this -> permissions -> where ( 'token' , $ permission ) -> isEmpty ( ) ) { return true ; } foreach ( $ this -> groups as $ group ) { foreach ( $ group -> roles as $ role ) { if ( ! $ role -> permissions -> where ( 'token' , $ permission ) -> isEmpty ( ) ) { retu... | Check if user has given permission |
5,814 | public function extractArgs ( $ args ) { foreach ( $ args as $ k => $ v ) { if ( property_exists ( $ this , $ k ) ) { $ this -> $ k = $ v ; } else { throw new \ InvalidArgumentException ( "{$k} is not a valid option." ) ; } } } | Loops through a given array and it the key exists as a property on this object it is assigned . |
5,815 | public function getDisplayValue ( $ formid = null ) { if ( $ formid && isset ( $ _SESSION [ $ formid ] [ $ this -> name ] ) ) { $ value = $ _SESSION [ $ formid ] [ $ this -> name ] ; } else if ( isset ( $ _POST [ $ this -> name ] ) ) { $ value = $ _POST [ $ this -> name ] ; } else { $ value = $ this -> defaultValue ; }... | Get the value to display in the form field . Either the value in the session post data the default value or nothing . |
5,816 | protected function cleanValue ( $ value ) { if ( is_array ( $ value ) ) { return array_map ( function ( $ v ) { return $ this -> cleanValue ( $ v ) ; } , $ value ) ; } else { return stripslashes ( $ value ) ; } } | Clean a value up for repopulation in a form field |
5,817 | public function validate ( ) { $ this -> errors = array ( ) ; $ value = $ this -> getRawValue ( ) ; if ( $ this -> required ) { $ passed = $ this -> validateRequired ( $ value ) ; if ( ! $ passed ) return $ this -> errors ; $ this -> validateType ( $ value ) ; $ this -> validatePattern ( $ value ) ; $ this -> validateM... | Validate a field |
5,818 | public function validateMaxLength ( $ value ) { if ( ! isset ( $ this -> attr [ "maxlength" ] ) ) return true ; $ maxlength = trim ( $ this -> attr [ "maxlength" ] ) ; $ length = strlen ( $ value ) ; if ( $ length > $ maxlength ) { $ this -> errors [ ] = "\"{$this->label}\" contains {$length} characters, but it is limi... | Validates the maximum length of a form element . |
5,819 | public function validatePattern ( $ value ) { if ( ! isset ( $ this -> attr [ "pattern" ] ) ) return true ; $ pattern = trim ( $ this -> attr [ "pattern" ] , "/" ) ; if ( ! preg_match ( "/{$pattern}/" , $ value ) ) { $ this -> errors [ ] = "\"{$this->label}\" must match the specified pattern." ; return false ; } return... | Validates a form element with a pattern attribute . |
5,820 | public function uri ( CryptographyEngine $ cryptographyEngine ) { $ uri = parent :: uri ( $ cryptographyEngine ) ; $ params = array ( 'hash' => $ cryptographyEngine -> hash ( $ this -> email ) , ) ; if ( null !== $ this -> action ) $ params [ 'action' ] = $ this -> action ; if ( null !== $ this -> scope ) $ params [ 's... | returns query parameter |
5,821 | public function response ( Response $ response , CryptographyEngine $ cryptographyEngine ) { $ decryptedResponse = new DecryptedCommandResponse ( $ response ) ; $ decryptedResponse -> assignCryptographyEngine ( $ cryptographyEngine , $ this -> email ) ; return $ decryptedResponse ; } | creates a response from http response |
5,822 | public function usernameAvailableAction ( Request $ request ) { $ response = array ( 'cssClass' => 'success' , 'text' => 'username is available' , ) ; $ user = $ this -> get ( 'userfriendly_social_user.oauth_user_provider' ) -> findOneByUsernameSlug ( $ request -> get ( 'username_slug' ) ) ; $ currentUser = $ this -> g... | AJAX action for checking username availability |
5,823 | private function showAndEdit ( Request $ request , $ action ) { $ user = $ this -> get ( 'userfriendly_social_user.oauth_user_provider' ) -> findOneByUsernameSlug ( $ request -> get ( 'username_slug' ) ) ; if ( $ user ) { $ currentUser = $ this -> get ( 'security.context' ) -> getToken ( ) -> getUser ( ) ; if ( self ::... | Private methods for use in this Controller s public methods |
5,824 | public function laraException ( Request $ request ) { $ storage = Storage :: disk ( 'local' ) ; $ fileName = base64_decode ( urldecode ( $ request -> get ( 'errors' ) ) ) ; if ( ! $ storage -> exists ( $ fileName ) ) { $ info = null ; } else { $ info = $ storage -> get ( $ fileName ) ; } $ view = self :: VIEW_DEFAULT ;... | Controlador encargado de validar que debe retornar si la vista o el response JSON |
5,825 | public function initialize ( array $ config ) { $ config = Hash :: merge ( $ this -> _defaultConfig , $ config ) ; $ this -> setConfig ( $ config ) ; } | Initialize hook . |
5,826 | protected function _clearCacheGroup ( ) { $ cacheGroups = ( array ) $ this -> getConfig ( 'groups' ) ; foreach ( $ cacheGroups as $ group ) { Cache :: clearGroup ( $ group , $ this -> getConfig ( 'config' ) ) ; } } | Clear cache group . |
5,827 | public function lister ( $ tag , array $ list ) { $ html = '' ; $ class = '' ; if ( $ space = strpos ( $ tag , ' ' ) ) { $ class = trim ( substr ( $ tag , $ space ) ) ; $ tag = substr ( $ tag , 0 , $ space ) ; } foreach ( $ list as $ key => $ value ) { if ( $ tag == 'dl' ) { $ html .= '<dt>' . $ key . '</dt>' ; $ html ... | This assists you in making Ordered Unordered and Definition lists . It is especially useful when you are nesting lists within lists . Your code almost looks exactly like you would expect to see it on the big screen . It would have been nice if we could have named this method list but someone has taken that already . |
5,828 | public function search ( $ url , array $ form = array ( ) ) { $ html = '' ; $ form = array_merge ( array ( 'name' => 'search' , 'role' => 'search' , 'class' => 'form-horizontal' , 'placeholder' => 'Search' , 'button' => $ this -> icon ( 'search' ) , 'size' => '' , ) , $ form ) ; $ form [ 'method' ] = 'get' ; $ form [ '... | This will assist you in creating a search bar for your site . |
5,829 | public function icon ( $ symbol , $ prefix = 'glyphicon' , $ tag = 'i' ) { $ base = $ prefix ; $ classes = explode ( ' ' , $ symbol ) ; $ prefix = array ( $ classes [ 0 ] ) ; $ params = '' ; if ( $ space = strpos ( $ tag , ' ' ) ) { $ params = ' ' . trim ( substr ( $ tag , $ space ) ) ; $ tag = substr ( $ tag , 0 , $ s... | Create an icon without the verbosity . |
5,830 | public function button ( $ class , $ name , array $ options = array ( ) ) { $ attributes = array ( 'type' => 'button' ) ; foreach ( $ options as $ key => $ value ) { if ( ! in_array ( $ key , array ( 'dropdown' , 'dropup' , 'active' , 'disabled' , 'pull' ) ) ) { $ attributes [ $ key ] = $ value ; } } $ attributes [ 'cl... | A button by itself is easy enough but when you start including dropdowns and groups your markup can get ugly quick . Follow the examples . We ll start simple and go from there . |
5,831 | public function group ( $ class , array $ buttons , $ form = '' ) { $ attributes = array ( 'class' => $ this -> prefixClasses ( 'btn-group' , array ( 'xs' , 'sm' , 'lg' , 'justified' , 'vertical' ) , $ class ) ) ; if ( $ form == 'checkbox' || $ form == 'radio' ) { $ attributes [ 'data-toggle' ] = 'buttons-' . $ form ; ... | Group your buttons together . |
5,832 | public function tabs ( array $ links , array $ options = array ( ) ) { $ class = 'nav nav-tabs' ; if ( isset ( $ options [ 'align' ] ) ) { switch ( $ options [ 'align' ] ) { case 'justified' : $ class .= ' nav-justified' ; break ; case 'left' : case 'right' : $ class .= ' pull-' . $ options [ 'align' ] ; break ; } } re... | Creates a Bootstrap tabs nav menu . |
5,833 | public function pills ( array $ links , array $ options = array ( ) ) { $ class = 'nav nav-pills' ; if ( isset ( $ options [ 'align' ] ) ) { switch ( $ options [ 'align' ] ) { case 'justified' : $ class .= ' nav-justified' ; break ; case 'vertical' : case 'stacked' : $ class .= ' nav-stacked' ; break ; case 'left' : ca... | Creates a Bootstrap pills nav menu . |
5,834 | public function breadcrumbs ( array $ links ) { if ( empty ( $ links ) ) { return '' ; } foreach ( $ links as $ name => $ href ) { if ( is_array ( $ href ) ) { list ( $ dropdown , $ id ) = $ this -> dropdown ( $ href ) ; $ link = $ this -> page -> tag ( 'a' , array ( 'href' => '#' , 'data-toggle' => 'dropdown' , 'id' =... | Creates a Bootstrap styled breadcrumb trail . The last link is automatically activated . |
5,835 | public function alert ( $ type , $ alert , $ dismissable = true ) { $ html = '' ; $ class = 'alert alert-' . $ type ; if ( $ dismissable ) { $ class .= ' alert-dismissable' ; } $ html .= '<div class="' . $ class . '" role="alert">' ; if ( $ dismissable ) { $ html .= '<button type="button" class="close" data-dismiss="al... | Creates Bootstrap alert messages . |
5,836 | public function progress ( $ percent , $ class = '' , $ display = false ) { $ html = '' ; $ classes = ( array ) $ class ; foreach ( ( array ) $ percent as $ key => $ progress ) { $ class = ( isset ( $ classes [ $ key ] ) ) ? $ classes [ $ key ] : '' ; $ class = $ this -> prefixClasses ( 'progress-bar' , array ( 'succes... | Creates every flavor of progress bar that Bootstrap has to offer . |
5,837 | public function panel ( $ class , array $ sections ) { $ html = '' ; foreach ( $ sections as $ panel => $ content ) { if ( ! is_numeric ( $ panel ) ) { $ panel = substr ( $ panel , 0 , 4 ) ; } switch ( ( string ) $ panel ) { case 'head' : $ html .= '<div class="panel-heading">' . $ this -> addClass ( $ content , array ... | Creates a Bootstrap panel component . |
5,838 | public function accordion ( $ class , array $ sections , $ open = 1 ) { $ html = '' ; $ count = 0 ; $ id = $ this -> page -> id ( 'accordion' ) ; foreach ( $ sections as $ head => $ body ) { ++ $ count ; $ heading = $ this -> page -> id ( 'heading' ) ; $ collapse = $ this -> page -> id ( 'collapse' ) ; $ in = ( $ open ... | Bootstrap accordions are basically collapsible panels . That is essentially what you are creating here . |
5,839 | public function carousel ( array $ images , array $ options = array ( ) ) { $ html = '' ; $ id = $ this -> page -> id ( 'carousel' ) ; $ options = array_merge ( array ( 'interval' => 5000 , 'indicators' => true , 'controls' => true , ) , $ options ) ; if ( $ options [ 'indicators' ] ) { $ indicators = array_keys ( arra... | Creates a Bootstrap carousel for cycling through elements . Those elements don t necessarily need to be images but pretty much they always are . |
5,840 | public function setKeyName ( $ keyName ) { $ this -> keyName = ( string ) $ keyName ; $ this -> keyCode = null ; $ this -> charPressed = null ; return $ this ; } | Set the key name for triggering the action |
5,841 | public function setCharPressed ( $ charPressed ) { $ this -> keyName = null ; $ this -> keyCode = null ; $ this -> charPressed = ( string ) $ charPressed ; return $ this ; } | Set the character to press for triggering the action |
5,842 | public function boot ( Container $ app ) { $ app -> afterResolving ( function ( Factory $ factory , $ app ) { $ factory -> addExtension ( 'php' , 'php' , function ( ) { return new PhpEngine ( ) ; } ) ; $ factory -> addExtension ( 'blade.php' , 'blade' , function ( ) use ( $ app ) { return new CompilerEngine ( $ app -> ... | Set up the various view engines . |
5,843 | public function getData ( $ rp , $ metric , $ tags , $ granularity = 'daily' , $ startDt = null , $ endDt = '2100-12-01T00:00:00Z' , $ timezone = 'UTC' ) { $ points = [ ] ; try { $ pointsRp = $ this -> mapper -> getRpPoints ( $ rp , $ metric , $ tags , $ granularity , $ startDt , $ endDt , $ timezone ) ; $ pointsTmp = ... | Get analytics data in right time zone by period and granularity |
5,844 | public function getTotal ( $ rp , $ metric , $ tags ) { try { $ todayDt = date ( "Y-m-d" ) . "T00:00:00Z" ; return $ this -> mapper -> getRpSum ( 'forever' , $ metric , $ tags ) + $ this -> mapper -> getRpSum ( $ rp , $ metric , $ tags , $ todayDt ) + $ this -> mapper -> getSum ( $ metric , $ tags ) ; } catch ( Excepti... | Returns analytics total for right metric |
5,845 | private function fixTimeForGranularity ( $ points , $ granularity ) { if ( $ granularity != $ this -> mapper :: GRANULARITY_DAILY ) { return $ points ; } foreach ( $ points as & $ value ) { $ date = substr ( $ value [ 'time' ] , 0 , 10 ) ; $ offset = substr ( $ value [ 'time' ] , - 6 ) ; $ value [ 'time' ] = $ date . "... | Fix time part for non - downsampled data |
5,846 | private function combineSumPoints ( $ points1 , $ points2 ) { $ pointsCount = count ( $ points1 ) ; $ currPoint = 0 ; foreach ( $ points2 as $ point2 ) { $ pointFound = false ; while ( $ currPoint < $ pointsCount ) { $ point1 = $ points1 [ $ currPoint ] ; if ( $ point1 [ 'time' ] == $ point2 [ 'time' ] ) { $ points1 [ ... | Combine downsampled and non - downsampled points |
5,847 | public function context ( $ context = null ) { if ( is_null ( $ context ) ) { return $ this -> context ; } $ this -> context = $ context ; return $ this ; } | Set field context of exception |
5,848 | public function args ( ) { $ this -> args = func_get_args ( ) ; $ params = array_merge ( array ( $ this -> formatMessage ) , $ this -> args ) ; $ this -> message = call_user_func_array ( 'sprintf' , $ params ) ; return $ this ; } | Get the arrguments passed and build message by them . |
5,849 | public function copy ( $ sourceDir , $ destinyDir ) { $ dir = opendir ( $ sourceDir ) ; $ this -> mkdir ( $ destinyDir ) ; while ( false !== ( $ file = readdir ( $ dir ) ) ) { if ( ( $ file != '.' ) && ( $ file != '..' ) ) { if ( is_dir ( $ sourceDir . '/' . $ file ) ) { $ this -> copy ( $ sourceDir . '/' . $ file , $ ... | Copy directory to destiny directory |
5,850 | public function getDocumentManager ( ) { if ( null === $ this -> dm ) { $ this -> dm = $ this -> getServiceLocator ( ) -> get ( 'doctrine.documentmanager.odm_default' ) ; } return $ this -> dm ; } | Retorna o DocumentManager . |
5,851 | public static function maker ( $ param , $ param2 = null ) { if ( ! is_null ( $ param2 ) ) { return static :: create ( $ param , $ param2 ) ; } $ param = explode ( ' ' , $ param ) ; $ element = array_shift ( $ param ) ; return static :: create ( $ element , implode ( ' ' , $ param ) ) ; } | The maker is like a development shortcut to create html elements on the go |
5,852 | public static function attr ( $ attr = array ( ) ) { $ buffer = " " ; foreach ( $ attr as $ key => $ value ) { switch ( $ key ) { case 'class' : if ( is_array ( $ value ) ) { $ value = implode ( ' ' , $ value ) ; } break ; case 'style' : if ( is_array ( $ value ) ) { $ style = $ value ; $ value = "" ; foreach ( $ style... | generates html attribute string |
5,853 | public static function tag ( $ name , $ param1 = null , $ param2 = null ) { return static :: create ( $ name , $ param1 , $ param2 ) ; } | generates an html tag |
5,854 | public function add_class ( $ class ) { if ( ! isset ( $ this -> attr [ 'class' ] ) || ! is_array ( $ this -> attr [ 'class' ] ) ) { $ this -> _sanitize_class ( ) ; } if ( strpos ( $ class , ' ' ) !== false ) { $ class = explode ( ' ' , $ class ) ; } if ( is_string ( $ class ) ) { $ class = array ( $ class ) ; } foreac... | add html class |
5,855 | public function remove_class ( $ class ) { if ( ! isset ( $ this -> attr [ 'class' ] ) || ! is_array ( $ this -> attr [ 'class' ] ) ) { $ this -> _sanitize_class ( ) ; } $ this -> attr [ 'class' ] = array_diff ( $ this -> attr [ 'class' ] , array ( $ class ) ) ; return $ this ; } | remove html class |
5,856 | private function _sanitize_class ( ) { if ( isset ( $ this -> attr [ 'class' ] ) && is_string ( $ this -> attr [ 'class' ] ) ) { $ this -> attr [ 'class' ] = explode ( ' ' , $ this -> attr [ 'class' ] ) ; } if ( ! isset ( $ this -> attr [ 'class' ] ) || ! is_array ( $ this -> attr [ 'class' ] ) ) { $ this -> attr [ 'cl... | clean the classes attribute |
5,857 | public function getConnectionConfig ( $ name = null ) { if ( is_null ( $ name ) ) { $ name = $ this -> defaultConfigName ; } if ( isset ( $ this -> connectionConfigs [ $ name ] ) ) { return $ this -> connectionConfigs [ $ name ] ; } return null ; } | Get connection config . |
5,858 | public function getConnection ( $ name = null , $ forceNew = false ) { if ( ! $ forceNew && isset ( $ this -> connections [ $ name ] ) ) { return $ this -> connections [ $ name ] ; } $ config = $ this -> getConnectionConfig ( $ name ) ; if ( ! $ config ) { return null ; } $ pdoArgs = [ $ config [ 'dsn' ] , $ config [ '... | Get a connection by name . |
5,859 | public function parseDate ( $ string ) { try { return new \ DateTime ( $ string ) ; } catch ( ParsingException $ ex ) { $ exception = new ParsingException ( 'The date is ' . 'not parsable' , 0 , $ ex ) ; throw $ exception ; } } | parse string expected to be a date and transform to a DateTime object |
5,860 | protected function recomposePattern ( array $ terms , array $ supportedTerms , $ domain = NULL ) { $ recomposed = '' ; if ( $ domain !== NULL ) { $ recomposed .= '@' . $ domain . ' ' ; } foreach ( $ supportedTerms as $ term ) { if ( array_key_exists ( $ term , $ terms ) && $ term !== '_default' ) { $ recomposed .= ' ' ... | recompose a pattern retaining only supported terms |
5,861 | public static function copyFromButtonable ( Buttonable $ tabButtonable ) { $ valueObject = new static ( ) ; $ valueObject -> setButtonLabel ( $ tabButtonable -> getButtonLabel ( ) ) ; $ valueObject -> setFullButtonLabel ( $ tabButtonable -> getFullButtonLabel ( ) ) ; $ valueObject -> setButtonLeftIcon ( $ tabButtonable... | Creates a copy of an Buttonable |
5,862 | protected function requirePackage ( Package $ package ) { $ version = $ this -> chooseVersion ( $ package ) ; passthru ( sprintf ( 'composer require %s:%s' , $ package -> getName ( ) , $ version ) ) ; $ this -> comment ( 'Package ' . $ package -> getName ( ) . ' installed' ) ; $ versions = $ package -> getVersions ( ) ... | Installs package . |
5,863 | protected function searchPackage ( $ packageName ) { $ this -> comment ( 'Searching for package...' ) ; $ packages = $ this -> packagist -> search ( $ packageName ) ; $ total = count ( $ packages ) ; if ( $ total === 0 ) { $ this -> comment ( 'No packages found' ) ; exit ; } $ this -> comment ( 'Found ' . $ total . ' p... | Perform search on packagist and ask package select . |
5,864 | protected function choosePackage ( $ packages ) { $ choose = $ this -> ask ( 'Select package by number [1]:' , '1' ) ; if ( ! is_numeric ( $ choose ) or ! isset ( $ packages [ $ choose - 1 ] ) ) { $ this -> error ( 'Incorrect value given!' ) ; $ this -> choosePackage ( $ packages ) ; } else { $ index = $ choose - 1 ; $... | Ask package select from a list . |
5,865 | protected function buildParams ( array $ params ) { $ normalizedParameters = array ( ) ; foreach ( $ params as $ parameter ) { if ( $ parameter instanceof GeneratorInstance ) { $ normalizedParameters [ ] = sprintf ( '$di->get(%s)' , '\'' . $ parameter -> getName ( ) . '\'' ) ; } else { $ normalizedParameters [ ] = var_... | Generates parameter strings to be used as injections replacing reference parameters with their respective getters |
5,866 | public function execAction ( Request $ request ) { ignore_user_abort ( true ) ; set_time_limit ( 0 ) ; $ this -> get ( 'anime_db.command' ) -> execute ( $ request -> get ( 'command' ) , 0 ) ; return new Response ( ) ; } | Execute command in background . |
5,867 | public function beforeMarshal ( Event $ event , \ ArrayObject $ data , \ ArrayObject $ options ) { $ this -> _prepareParamsData ( $ data ) ; } | Callback before request data is converted into entities . |
5,868 | protected function _prepareParamsData ( \ ArrayObject $ data ) { if ( isset ( $ data [ 'params' ] ) ) { $ params = new JSON ( ( array ) $ data [ 'params' ] ) ; $ data -> offsetSet ( 'params' , $ params ) ; } } | Prepare params data . |
5,869 | public function boot ( ) { $ registryServiceName = 'service_provider_registry_' . $ this -> id ; $ this -> container -> set ( $ registryServiceName , $ this -> getRegistry ( $ this -> container ) ) ; } | At boot time let s fill the container with the registry . |
5,870 | public function getSessions ( ) { $ sessions = array ( ) ; $ result = $ this -> curl ( 'GET' , '/sessions' ) ; foreach ( $ result [ 'value' ] as $ session ) { $ sessions [ ] = new WebDriverSession ( $ this -> url . '/session/' . $ session [ 'id' ] ) ; } return $ sessions ; } | get a list of active sessions |
5,871 | public function getSize ( $ path ) { $ location = $ this -> applyPathPrefix ( $ path ) ; $ response = $ this -> ossClient -> getObjectMeta ( $ this -> bucket , $ location ) ; return [ 'size' => $ response [ 'content-length' ] ] ; } | Get the size of a file . |
5,872 | public static function charset ( $ charset = null ) { switch ( $ charset ) { case 'pass' : case 'secure' : case 'password' : return static :: SECURE ; break ; case 'key' : return static :: KEY ; break ; case 'alphanum' : return static :: ALPHA_NUM ; break ; case 'alpha' : return static :: ALPHA ; break ; case 'alpha_lo... | Get a charset a string containing a set of characters . |
5,873 | public static function random ( $ length = 25 , $ charset = null ) { $ charset = static :: charset ( $ charset ) ; $ count = strlen ( $ charset ) ; $ string = '' ; while ( $ length -- ) { $ string .= $ charset [ mt_rand ( 0 , $ count - 1 ) ] ; } return $ string ; } | Generate a random string with the given length and charset . |
5,874 | public static function capture ( $ callback , $ params = array ( ) ) { if ( is_string ( $ callback ) ) { return $ callback ; } if ( ! is_closure ( $ callback ) ) { return "" ; } if ( ! is_array ( $ params ) ) { $ params = array ( $ params ) ; } ob_start ( ) ; $ return = call_user_func_array ( $ callback , $ params ) ; ... | Try to get a string from a callback reading the output buffer |
5,875 | public static function htmlentities ( $ string , $ recursive = false ) { if ( is_array ( $ string ) ) { foreach ( $ string as $ key => $ item ) { if ( $ recursive ) { if ( is_array ( $ item ) ) { $ string [ $ key ] = static :: htmlentities ( $ item , $ recursive ) ; } } if ( is_string ( $ item ) ) { $ string [ $ key ] ... | Does the same as the PHP native htmlentities function but you can pass arrays . |
5,876 | public static function suffix ( $ string , $ sep = '-' ) { return substr ( $ string , strrpos ( $ string , $ sep ) + strlen ( $ sep ) ) ; } | Get the last part of a string |
5,877 | public static function clean_url ( $ string , $ sep = null ) { $ string = strtolower ( static :: replace_accents ( trim ( $ string ) ) ) ; $ string = str_replace ( array ( ' ' , '&' , '\r\n' , '\n' , '+' , ',' , '.' , '_' ) , '-' , $ string ) ; $ string = preg_replace ( array ( '/[^a-z0-9\-]/' , '/[\-]+/' , ) , array (... | Try to form a string to url valid segment . It will remove all special characters replace accents characters remove and replace whitespaces breaks etc .. |
5,878 | public static function replace ( $ string , $ arr , $ count = null ) { return str_replace ( array_keys ( $ arr ) , array_values ( $ arr ) , $ string , $ count ) ; } | str_replace using key = > value of an array |
5,879 | public static function preg_replace ( $ arr , $ string , $ count = null ) { return preg_replace ( array_keys ( $ arr ) , array_values ( $ arr ) , $ string , $ count ) ; } | preg replace using key = > value of an array |
5,880 | public static function lower ( $ string , $ encoding = null ) { if ( is_null ( $ encoding ) ) { $ encoding = ClanCats :: $ config -> charset ; } return mb_strtolower ( $ string , $ encoding ) ; } | Converts an string to lowercase using the system encoding |
5,881 | public static function upper ( $ string , $ encoding = null ) { if ( is_null ( $ encoding ) ) { $ encoding = ClanCats :: $ config -> charset ; } return mb_strtoupper ( $ string , $ encoding ) ; } | Converts an string to uppercase using the system encoding |
5,882 | public static function cut ( $ string , $ key , $ cut_key = true , $ last = false ) { if ( $ last ) { $ pos = strrpos ( $ string , $ key ) ; } else { $ pos = strpos ( $ string , $ key ) ; } if ( $ pos === false ) { return $ string ; } if ( ! $ cut_key ) { $ pos += strlen ( $ key ) ; } return substr ( $ string , 0 , $ p... | Cuts a string after another string . |
5,883 | public static function bytes ( $ size , $ round = 2 ) { $ unit = array ( 'b' , 'kb' , 'mb' , 'gb' , 'tb' , 'pb' ) ; return @ round ( $ size / pow ( 1024 , ( $ i = floor ( log ( $ size , 1024 ) ) ) ) , $ round ) . $ unit [ $ i ] ; } | Convert bytes to a human readable format |
5,884 | public function localize ( array $ translatableStrings ) { if ( NULL === $ translatableStrings ) { return NULL ; } $ language = $ this -> requestStack -> getCurrentRequest ( ) -> getLocale ( ) ; if ( isset ( $ translatableStrings [ $ language ] ) ) { return $ translatableStrings [ $ language ] ; } else { foreach ( $ th... | return the string in current locale if it exists . |
5,885 | public function increment ( $ key , $ delta = 1 ) { if ( $ this -> has ( $ key ) ) { $ this -> set ( $ key , $ this -> get ( $ key ) + $ delta ) ; } else { $ this -> set ( $ key , $ delta ) ; } return $ this ; } | Increment the value stored at the given key by the given delta . |
5,886 | public function declareCreation ( string $ table , array $ columns ) { $ source = $ this -> method ( 'up' ) -> getSource ( ) ; $ source -> addLine ( "\$this->table('{$table}')" ) ; foreach ( $ columns as $ name => $ type ) { $ source -> addLine ( " ->addColumn('{$name}', '{$type}')" ) ; } $ source -> addLine ( " ... | Declare table creation with specific set of columns |
5,887 | public function apply ( $ method , array $ args = [ ] ) { $ result = new Map ; $ this -> walk ( function ( $ object , $ key ) use ( $ method , $ args , $ result ) { $ result [ $ key ] = call_user_func_array ( [ $ object , $ method ] , $ args ) ; } ) ; return $ result ; } | Call the given method on every object in the map and return the results as a new map . |
5,888 | public function addFeature ( FeatureInterface $ feature ) { $ this -> features -> set ( $ feature -> getKey ( ) , $ feature ) ; return $ this ; } | Add a feature to the container |
5,889 | protected function assignUserToUserGroups ( User $ user , array $ userGroupObjects ) { $ ezUserGroups = [ ] ; foreach ( $ userGroupObjects as $ userGroup ) { $ userGroup = $ this -> userGroupManager -> createOrUpdate ( $ userGroup ) ; if ( $ userGroup instanceof UserGroupObject ) { $ ezUserGroup = $ this -> userGroupMa... | Assigns a collection of Transfer user groups from an eZ user and returns the once who were added . |
5,890 | protected function unassignUserFromUserGroups ( User $ user , array $ userGroups ) { $ existingUserGroups = $ this -> userService -> loadUserGroupsOfUser ( $ user ) ; foreach ( $ existingUserGroups as $ existingUserGroup ) { if ( ! array_key_exists ( $ existingUserGroup -> id , $ userGroups ) ) { $ this -> userService ... | Unassigns a collection of eZ UserGroups from an eZ User . |
5,891 | public function request ( $ method , $ endpoint , array $ parameters = null ) { $ url = $ this -> config -> getEndpoint ( ) . $ endpoint ; $ headers = array ( 'Authorization' => 'Bearer ' . $ this -> config -> getAccessToken ( ) ) ; return $ this -> client -> request ( $ method , $ url , $ parameters , $ headers ) ; } | Send an authenticated api request |
5,892 | public function log ( $ message , $ flag ) { $ headers = [ 'token' => $ this -> token , ] ; $ query = $ this -> processLog ( $ message , $ flag ) ; $ response = $ this -> curl :: post ( $ this -> missionControlUrl , $ headers , $ query ) ; if ( $ response -> code != 200 ) { $ this -> error ( 'Unable to message Mission ... | Send the log to Mission Control |
5,893 | protected function baseRequest ( ) { return [ 'report_referer' => $ this -> server ( 'HTTP_REFERER' , '' ) , 'report_user_agent' => $ this -> server ( 'HTTP_USER_AGENT' , '' ) , 'report_host' => $ this -> server ( 'HTTP_HOST' , '' ) , 'report_server_name' => $ this -> server ( 'SERVER_NAME' , '' ) , 'report_remote_addr... | Collect basic server info |
5,894 | public function addFieldDefinitionObject ( $ identifier , $ fieldDefinition ) { $ this -> data [ 'fields' ] [ $ identifier ] = $ this -> convertToFieldDefintionObject ( $ identifier , $ fieldDefinition ) ; } | Convert parameters to FieldDefinitionObject and stores it on the ContentTypeObject . |
5,895 | private function setMissingDefaults ( ) { if ( ! isset ( $ this -> data [ 'contenttype_groups' ] ) ) { $ this -> data [ 'contenttype_groups' ] = array ( 'Content' ) ; } if ( $ this -> notSetOrEmpty ( $ this -> data , 'names' ) ) { $ this -> data [ 'names' ] = array ( $ this -> data [ 'main_language_code' ] => $ this ->... | Build default values . |
5,896 | function removeTeam ( $ competitionId , $ teamId ) { if ( ! $ competitionId ) { throw new Exception ( 'Invalid competitionId' ) ; } if ( ! $ teamId ) { throw new Exception ( 'Invalid teamId' ) ; } return $ this -> execute ( 'DELETE' , '/competitions/%d/teams/%d/' , array ( $ competitionId , $ teamId ) ) ; } | Works only during the registration phase |
5,897 | function registerResults ( $ competitionId , array $ results ) { if ( ! $ competitionId ) { throw new Exception ; } if ( ! $ results ) { throw new Exception ; } return $ this -> execute ( 'POST' , '/competitions/%d/results/' , array ( $ competitionId , array ( $ results ) ) ) ; } | Register final results of your competition |
5,898 | public function del ( $ cookie ) { if ( empty ( $ cookie ) ) throw new CookieException ( "Invalid cookie object or name" ) ; $ name = ( $ cookie instanceof CookieInterface ) ? $ cookie -> getName ( ) : $ cookie ; if ( $ this -> isRegistered ( $ name ) ) { unset ( $ this -> cookies [ $ name ] ) ; } else { throw new Cook... | Delete a cookie from the stack |
5,899 | public function has ( $ cookie ) { if ( empty ( $ cookie ) ) throw new CookieException ( "Invalid cookie object or name" ) ; $ name = ( $ cookie instanceof CookieInterface ) ? $ cookie -> getName ( ) : $ cookie ; return array_key_exists ( $ name , $ this -> cookies ) ; } | Check if a cookie is into the stack |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.