idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
7,200 | public function setStatusForProduct ( ProductInterface $ product , $ statusId ) { if ( $ product -> getStatus ( ) && $ product -> getStatus ( ) -> getId ( ) === $ statusId ) { return ; } $ status = $ this -> statusRepository -> find ( $ statusId ) ; if ( ! $ status ) { throw new ProductDependencyNotFoundException ( sel... | Sets the status for a given product . |
7,201 | public function setDeliveryStatusForProduct ( $ product , $ statusId ) { $ status = $ this -> deliveryStatusRepository -> find ( $ statusId ) ; if ( ! $ status ) { throw new ProductDependencyNotFoundException ( self :: $ productStatusEntityName , $ statusId ) ; } $ product -> setDeliveryStatus ( $ status ) ; } | Sets the deliveryStatus for a given product . |
7,202 | protected function updatePrice ( ProductPrice $ price , $ matchedEntry ) { if ( isset ( $ matchedEntry [ 'minimumQuantity' ] ) ) { $ price -> getEntity ( ) -> setMinimumQuantity ( $ matchedEntry [ 'minimumQuantity' ] ) ; } if ( isset ( $ matchedEntry [ 'price' ] ) ) { $ price -> setPrice ( $ matchedEntry [ 'price' ] ) ... | Updates the given price with the values from the given array . |
7,203 | protected function addPrice ( ProductInterface $ product , $ priceData ) { if ( isset ( $ priceData [ 'id' ] ) ) { throw new EntityIdAlreadySetException ( self :: $ productPriceEntityName , $ priceData [ 'id' ] ) ; } elseif ( isset ( $ priceData [ 'price' ] ) ) { $ currency = $ this -> currencyRepository -> find ( $ pr... | Adds a price to the given product . |
7,204 | protected function removePrice ( ProductInterface $ product , ProductPriceEntity $ price ) { $ this -> em -> remove ( $ price ) ; $ product -> removePrice ( $ price ) ; return true ; } | Removes a price from the given product . |
7,205 | protected function addCategory ( ProductInterface $ product , $ categoryData ) { $ category = $ this -> categoryRepository -> find ( $ categoryData [ 'id' ] ) ; if ( ! $ category ) { throw new ProductDependencyNotFoundException ( self :: $ categoryEntityName , $ categoryData [ 'id' ] ) ; } $ product -> addCategory ( $ ... | Adds a category to the given product . |
7,206 | protected function processAttributes ( array $ data , ProductInterface $ product , $ locale ) { if ( isset ( $ data [ 'attributes' ] ) ) { $ productAttributes = [ ] ; foreach ( $ product -> getProductAttributes ( ) as $ productAttribute ) { $ productAttributes [ $ productAttribute -> getAttribute ( ) -> getId ( ) ] = $... | Processes attributes of data array . |
7,207 | private function retrieveAttributeById ( $ attributeId ) { $ attribute = $ this -> attributeRepository -> find ( $ attributeId ) ; if ( ! $ attribute ) { throw new ProductDependencyNotFoundException ( self :: $ attributeEntityName , $ attributeId ) ; } return $ attribute ; } | Finds an attribute with the given id . Else throws an Exception . |
7,208 | private function addAllCurrencies ( ProductInterface $ product ) { $ currencies = $ this -> currencyRepository -> findAll ( ) ; foreach ( $ product -> getPrices ( ) as $ price ) { if ( ( $ key = array_search ( $ price -> getCurrency ( ) , $ currencies ) ) !== false ) { unset ( $ currencies [ $ key ] ) ; } } foreach ( $... | Adds an ProductPrice for every currency to the Product if it is no existing already . |
7,209 | public function getFilters ( Request $ request ) { $ filter = [ ] ; $ statuses = $ request -> get ( 'status' ) ; if ( $ statuses ) { $ filter [ 'status' ] = explode ( ',' , $ statuses ) ; } $ statusIds = $ request -> get ( 'status_id' ) ; if ( $ statusIds ) { $ filter [ 'status_id' ] = explode ( ',' , $ statusIds ) ; }... | Get filters provided by the request . |
7,210 | final public function addTopics ( TopicFilter ... $ topics ) : self { foreach ( $ topics as $ topic ) { $ topicName = $ topic -> getTopicFilter ( ) ; if ( \ in_array ( $ topicName , $ this -> topicHashTable , true ) === false ) { $ this -> topicHashTable [ ] = $ topicName ; $ this -> topics -> enqueue ( $ topic ) ; } }... | A subscription is based on filters this function allows us to pass on filters |
7,211 | public function checkForEvent ( ClientInterface $ client ) : ReadableContentInterface { $ this -> checkPingTime ( $ client ) ; $ publishPacketControlField = $ client -> readBrokerData ( 1 ) ; $ eventManager = new EventManager ( $ this -> logger ) ; if ( ( \ ord ( $ publishPacketControlField ) & 255 ) > 0 ) { $ this -> ... | Performs a check on the socket connection and returns either the contents or an empty object |
7,212 | public function loop ( ClientInterface $ client , int $ idleMicroseconds = 100000 , callable $ hookBeforeLoop = null ) : \ Generator { $ this -> shouldLoop = true ; $ this -> logger -> debug ( 'Beginning loop' , [ 'idleMicroseconds' => $ idleMicroseconds ] ) ; $ readableContent = $ client -> processObject ( $ this ) ; ... | Loop and yields different type of results back whenever they are available |
7,213 | public function getSubtitleUrls ( array $ subtitles , $ all = false ) { $ subtitlesUrls = array ( ) ; if ( ! empty ( $ subtitles [ 'data' ] ) ) { foreach ( $ subtitles [ 'data' ] as $ sub ) { if ( ! empty ( $ sub [ 'SubDownloadLink' ] ) ) { $ subtitlesUrls [ ] = $ sub [ 'SubDownloadLink' ] ; if ( $ all === false ) { re... | Retrieve the url of the first subtitle found |
7,214 | public function getAction ( Request $ request , $ productId ) { $ locale = $ request -> get ( 'locale' ) ; $ product = $ this -> fetchProduct ( $ productId ) ; $ content = $ this -> getProductContentMapper ( ) -> get ( $ product , $ locale ) ; $ view = $ this -> view ( $ content , Response :: HTTP_OK ) ; return $ this ... | Action for receiving contents of a given product . |
7,215 | public function putAction ( Request $ request , $ productId ) { $ locale = $ request -> get ( 'locale' ) ; $ parameters = $ request -> request -> all ( ) ; $ product = $ this -> fetchProduct ( $ productId ) ; $ content = $ this -> getProductContentMapper ( ) -> map ( $ product , $ parameters , $ locale ) ; $ this -> ge... | Put action to update content of a product . |
7,216 | public function fetchProduct ( $ productId ) { $ product = $ this -> getProductRepository ( ) -> find ( $ productId ) ; if ( ! $ product ) { throw new EntityNotFoundException ( $ this -> getProductRepository ( ) -> getClassName ( ) , $ productId ) ; } return $ product ; } | Fetches product by id from database . |
7,217 | private function getCountryByCode ( $ code ) { if ( array_key_exists ( $ code , $ this -> countries ) ) { return $ this -> countries [ $ code ] ; } $ country = $ this -> manager -> getRepository ( static :: $ countryEntityName ) -> findOneBy ( [ 'code' => $ code ] ) ; if ( ! $ country ) { throw new \ Doctrine \ ORM \ E... | Finds country by code and caches it . |
7,218 | public function mail ( Swift_Mime_Message $ message ) { $ this -> message = $ message ; $ this -> createPreviewDirectory ( ) ; $ this -> files -> put ( $ this -> path ( ) , $ this -> content ( ) ) ; $ this -> setSession ( ) ; $ this -> cleanOldPreviews ( ) ; } | Perform the Debug Mail Actions . |
7,219 | private function filename ( ) { $ to = str_replace ( [ '@' , '.' ] , [ '_at_' , '_' ] , array_keys ( $ this -> message -> getTo ( ) ) [ 0 ] ) ; return str_slug ( $ this -> message -> getDate ( ) . '_' . $ to . '_' . $ this -> message -> getSubject ( ) , '_' ) . '.html' ; } | Return the Debug Mail Filename . |
7,220 | protected function appendToResponse ( Response $ response ) { $ existingContent = $ response -> getContent ( ) ; $ closeBodyPosition = strripos ( $ existingContent , '</body>' ) ; $ appendedContent = " <script> window.open('" . route ( 'mail-debug' , [ 'file' => $ this -> debug -> preview ( ) ... | Injects the Mail Debug Popup into the Response . |
7,221 | public function camel ( ) { if ( $ this -> areTitleCase ) { if ( ! preg_match ( '@^[[:upper:]]+$@' , $ this -> pieces [ 0 ] ) ) { $ this -> pieces [ 0 ] = lcfirst ( $ this -> pieces [ 0 ] ) ; } } else { $ first_piece = array_shift ( $ this -> pieces ) ; $ this -> pieces = array_map ( 'ucfirst' , $ this -> pieces ) ; ar... | Outputs the pieces as a camel case string . |
7,222 | public function pascal ( ) { if ( ! $ this -> areTitleCase ) { $ this -> pieces = array_map ( 'ucfirst' , $ this -> pieces ) ; } return implode ( '' , $ this -> pieces ) ; } | Outputs the pieces as a pascal case string . |
7,223 | public function snake ( ) { if ( $ this -> areTitleCase ) { foreach ( $ this -> pieces as & $ piece ) { if ( preg_match ( '@^[[:upper:]]+$@' , $ piece ) ) { continue ; } $ piece = lcfirst ( $ piece ) ; } } return implode ( '_' , $ this -> pieces ) ; } | Outputs the pieces as a snak case string . |
7,224 | public function start ( ) { $ this -> loop = React \ EventLoop \ Factory :: create ( ) ; $ socket = new React \ Socket \ Server ( $ this -> loop ) ; $ http = new React \ Http \ Server ( $ socket ) ; $ http -> on ( 'request' , $ function = $ this -> requestHandler -> getHandlerFunction ( ) ) ; $ socket -> listen ( $ thi... | start the loop |
7,225 | protected function _read ( $ id ) { if ( isset ( $ this -> cache [ $ id ] ) ) { $ item = $ this -> cache [ $ id ] ; if ( ! $ item -> is_valid ( ) ) { unset ( $ this -> cache [ $ id ] ) ; return false ; } return $ item -> data ; } return false ; } | Get an item from the cache if it s still valid otherwise exire it and return false . |
7,226 | public function clean ( $ maxlifetime , $ next ) { $ this -> cache = array_filter ( $ this -> cache , function ( $ item ) use ( $ maxlifetime ) { return $ item -> is_valid ( $ maxlifetime ) ; } ) ; return $ next ( $ maxlifetime ) ; } | Update the internal cache by filtering out any items that are no longer valid . |
7,227 | public function read ( $ id , $ next ) { $ data = $ this -> _read ( $ id ) ; if ( false === $ data ) { $ data = $ next ( $ id ) ; if ( false !== $ data ) { $ item = new MemoryItem ( $ data ) ; $ this -> cache [ $ id ] = $ item ; } } return $ data ; } | Grab the item from the cache if it exists otherwise delve deeper into the stack and retrieve from another underlying middlware . |
7,228 | protected function calc ( ) { if ( ! file_exists ( $ this -> track ) ) throw new \ Exception ( "File '{$this->track}' doesn't exist" ) ; $ length = $ this -> track -> getLength ( ) ; $ rate = null ; $ sample_count = $ this -> track -> getSampleCount ( ) ; $ trim = null ; if ( $ this -> offset || $ this -> duration ) { ... | Calculate the samples . |
7,229 | protected function calcExecute ( $ sample_count , $ trim , $ rate ) { $ track = escapeshellarg ( $ this -> track ) ; if ( $ trim ) $ trim = "trim $trim" ; $ resample = $ rate ? "-r $rate" : '' ; $ chunk_size = floor ( $ sample_count / $ this -> width ) ; $ descriptorspec = array ( 1 => array ( "pipe" , "w" ) , 2 => arr... | Calculate the samples |
7,230 | public function plot ( ) { $ this -> getSamples ( ) ; $ im = imagecreatetruecolor ( $ this -> width , $ this -> height ) ; imagesavealpha ( $ im , true ) ; imagefill ( $ im , 0 , 0 , imagecolorallocatealpha ( $ im , 0 , 0 , 0 , 127 ) ) ; $ center = ( $ this -> height / 2 ) ; $ scale = ( $ center / $ this -> level ) ; $... | Plot the waveform |
7,231 | protected static function strToColor ( $ im , $ color ) { $ color = ltrim ( $ color , '#' ) ; if ( strpos ( $ color , ',' ) !== false ) { list ( $ red , $ green , $ blue , $ opacity ) = explode ( ',' , $ color ) + [ 3 => null ] ; } else { $ red = hexdec ( substr ( $ color , 0 , 2 ) ) ; $ green = hexdec ( substr ( $ col... | Create a gd color using a hexidecimal color notation |
7,232 | public function retrieveCookieLanguage ( ) { if ( Yii :: $ app instanceof \ yii \ web \ Application === false ) { return ; } if ( Yii :: $ app -> request -> cookies -> has ( 'language_id' ) ) { $ language_id = intval ( Yii :: $ app -> request -> cookies -> get ( 'language_id' ) -> value ) ; if ( call_user_func ( [ $ th... | Retrieves language form cookie |
7,233 | private function getEmailObject ( $ emails ) { foreach ( $ emails as $ email ) { if ( $ email [ 'primary' ] && $ email [ 'verified' ] ) { return $ email ; } } foreach ( $ emails as $ email ) { if ( $ email [ 'primary' ] ) { return $ email ; } } return $ emails [ 0 ] ; } | Get the right email address from the one s the user provides . |
7,234 | public function registerService ( $ serviceName , $ className ) { if ( ! class_exists ( $ className ) ) { throw new Exception ( sprintf ( 'Service class %s does not exist.' , $ className ) ) ; } $ reflClass = new \ ReflectionClass ( $ className ) ; foreach ( [ 'OAuth2' , 'OAuth1' ] as $ version ) { if ( $ reflClass -> ... | Register a custom service to classname mapping . |
7,235 | public function createService ( $ serviceName , CredentialsInterface $ credentials , TokenStorageInterface $ storage , $ scopes = [ ] , Url $ baseApiUri = null , $ apiVersion = "" ) { foreach ( $ this -> serviceBuilders as $ version => $ buildMethod ) { $ fullyQualifiedServiceName = $ this -> getFullyQualifiedServiceNa... | Builds and returns oauth services It will first try to build an OAuth2 service and if none found it will try to build an OAuth1 service |
7,236 | private function getFullyQualifiedServiceName ( $ serviceName , $ type ) { $ serviceName = ucfirst ( $ serviceName ) ; if ( isset ( $ this -> serviceClassMap [ $ type ] [ $ serviceName ] ) ) { return $ this -> serviceClassMap [ $ type ] [ $ serviceName ] ; } return '\\' . __NAMESPACE__ . '\\' . $ type . '\\Service\\' .... | Gets the fully qualified name of the service |
7,237 | private function buildV2Service ( $ serviceName , CredentialsInterface $ credentials , TokenStorageInterface $ storage , array $ scopes , Url $ baseApiUri = null , $ apiVersion = "" ) { return new $ serviceName ( $ credentials , $ this -> getHttpTransporter ( ) , $ storage , $ this -> resolveScopes ( $ serviceName , $ ... | Builds v2 services |
7,238 | private function resolveScopes ( $ serviceName , array $ scopes ) { $ reflClass = new \ ReflectionClass ( $ serviceName ) ; $ constants = $ reflClass -> getConstants ( ) ; $ resolvedScopes = [ ] ; foreach ( $ scopes as $ scope ) { $ key = strtoupper ( 'SCOPE_' . $ scope ) ; if ( array_key_exists ( $ key , $ constants )... | Resolves scopes for v2 services |
7,239 | private function buildV1Service ( $ serviceName , CredentialsInterface $ credentials , TokenStorageInterface $ storage , $ scopes , Url $ baseApiUri = null ) { if ( ! empty ( $ scopes ) ) { throw new Exception ( 'Scopes passed to ServiceFactory::createService but an OAuth1 service was requested.' ) ; } return new $ ser... | Builds v1 services |
7,240 | public function respond ( $ payload = [ ] ) { if ( $ meta = $ this -> getMeta ( ) ) { $ payload = array_merge ( $ payload , [ 'meta' => $ meta ] ) ; } if ( config ( 'api.convert' ) ) { $ payload = PayloadConverter :: run ( $ payload ) ; } $ statusCode = ( config ( 'api.suppress_response_code' ) === true ) ? StatusCode ... | Generic response . |
7,241 | public function withCollection ( $ collection , $ transformer = null , $ resourceKey = null ) { return $ this -> respond ( $ this -> getCollection ( $ collection , $ transformer , $ resourceKey ) ) ; } | Respond collection of resources . |
7,242 | public function getCollection ( $ collection , $ transformer = null , $ resourceKey = null ) { $ resource = new FractalCollection ( $ collection , $ this -> getTransformer ( $ transformer ) , $ this -> getResourceKey ( $ resourceKey ) ) ; if ( $ meta = $ this -> getMeta ( ) ) { $ resource -> setMeta ( $ meta ) ; $ this... | Create FractalCollection payload . |
7,243 | public function withItem ( EloquentModel $ model , $ transformer = null , $ resourceKey = null ) { return $ this -> respond ( $ this -> getItem ( $ model , $ transformer , $ resourceKey ) ) ; } | Respond single item . |
7,244 | public function getItem ( EloquentModel $ model , $ transformer = null , $ resourceKey = null ) { $ resource = new FractalItem ( $ model , $ this -> getTransformer ( $ transformer ) , $ this -> getResourceKey ( $ resourceKey ) ) ; if ( $ meta = $ this -> getMeta ( ) ) { $ resource -> setMeta ( $ meta ) ; $ this -> meta... | Create FractalItem payload . |
7,245 | public function withPagination ( LengthAwarePaginator $ paginator , $ transformer = null , $ resourceKey = null ) { return $ this -> respond ( $ this -> getPagination ( $ paginator , $ transformer , $ resourceKey ) ) ; } | Respond collection of resources with pagination . |
7,246 | public function getPagination ( LengthAwarePaginator $ paginator , $ transformer = null , $ resourceKey = null ) { $ queryParams = array_diff_key ( $ _GET , array_flip ( [ 'page' ] ) ) ; foreach ( $ queryParams as $ key => $ value ) { $ paginator -> appends ( $ key , $ value ) ; } $ collection = $ paginator -> getColle... | Create FractalCollection payload with pagination . |
7,247 | public function created ( $ primitive = 'Created' ) { $ payload = null ; if ( $ primitive instanceof EloquentModel ) { return $ this -> setStatusCode ( StatusCode :: CREATED ) -> withItem ( $ primitive ) ; } return $ this -> setStatusCode ( StatusCode :: CREATED ) -> respond ( $ this -> format ( $ primitive , config ( ... | Respond 201 . |
7,248 | public function error ( $ message = 'Unknown Error' ) { $ format = config ( 'api.errorFormat' ) ; if ( $ message instanceof \ Exception ) { if ( config ( 'api.debug' ) === true ) { $ format [ 'debug' ] = [ 'line' => $ message -> getLine ( ) , 'file' => $ message -> getFile ( ) , 'class' => get_class ( $ message ) , 'tr... | Generic error response . |
7,249 | public function getHeaders ( ) { $ defaultHeaders = config ( 'api.defaultHeaders' ) ; return $ defaultHeaders ? array_merge ( $ defaultHeaders , $ this -> headers ) : $ this -> headers ; } | Getter for headers property . |
7,250 | public function setHeaders ( array $ headers ) { if ( $ headers ) { $ this -> headers = array_merge ( $ this -> headers , $ headers ) ; } return $ this ; } | Setter for headers property . |
7,251 | public function format ( $ message , array $ format ) { $ replace = [ ':message' => $ message , ':code' => $ this -> getStatusCode ( ) , ] ; array_walk_recursive ( $ format , function ( & $ value , $ key ) use ( $ replace ) { if ( isset ( $ replace [ $ value ] ) ) { $ value = $ replace [ $ value ] ; } } ) ; return $ fo... | Build response payload array based on configured format . |
7,252 | private function translateExceptionCode ( $ e ) { if ( ! in_array ( $ e -> getCode ( ) , [ 0 , - 1 , null , '' ] ) ) { return $ e -> getCode ( ) ; } if ( method_exists ( $ e , 'getStatusCode' ) ) { if ( ! in_array ( $ e -> getStatusCode ( ) , [ 0 , - 1 , null , '' ] ) ) { return $ e -> getStatusCode ( ) ; } if ( ( $ st... | Translate http status code based on the given exception . |
7,253 | public function byId ( $ id , $ fields = null ) { if ( is_null ( $ fields ) ) { $ fields = self :: $ defaultFields ; } return $ this -> get ( "employees/{$id}/" , [ 'fields' => implode ( ',' , $ fields ) ] ) ; } | Returns an employee identified by the given ID |
7,254 | public function add ( array $ fields ) { $ xml = "<employee>" ; foreach ( $ fields as $ field => $ value ) { $ xml .= "<field id=\"{$field}\">{$value}</field>" ; } $ xml .= "</employee>" ; return $ this -> post ( "employees" , $ xml ) ; } | Add a new employee |
7,255 | public function update ( $ id , array $ fields ) { $ xml = "<employee>" ; foreach ( $ fields as $ field => $ value ) { $ xml .= "<field id=\"{$field}\">{$value}</field>" ; } $ xml .= "</employee>" ; return $ this -> post ( "employees/{$id}" , $ xml ) ; } | Update an existing employee identified by their ID |
7,256 | public function import ( array $ data ) { $ xml = "<employees>" ; foreach ( $ data as $ user ) { $ xml .= "<employee" ; $ xml .= ( isset ( $ user [ 'number' ] ) ? " number=\"{$user['number']}\">" : ">" ) ; foreach ( $ user as $ key => $ value ) { if ( $ key == "number" ) { continue ; } if ( is_array ( $ value ) ) { $ x... | An undocumented BambooHR API endpoint for bulk importing employees . |
7,257 | public function make ( ) { if ( is_lumen ( ) ) { return new \ Laravel \ Lumen \ Http \ ResponseFactory ( ) ; } return app ( \ Illuminate \ Contracts \ Routing \ ResponseFactory :: class ) ; } | Create an instance of Laravel or Lumen ResponseFactory |
7,258 | public function isValidScope ( $ scope ) { $ reflectionClass = new \ ReflectionClass ( get_class ( $ this ) ) ; return in_array ( $ scope , $ reflectionClass -> getConstants ( ) , true ) ; } | Return whether or not the passed scope value is valid . |
7,259 | public function listen ( $ port , $ host = '0.0.0.0' ) { $ this -> port = $ port ; $ this -> host = $ host ; return $ this ; } | Setup for listen requests |
7,260 | function getConnector ( ) { if ( empty ( $ this -> connector ) ) $ this -> connector = new Connector ( $ this -> config ) ; return $ this -> connector ; } | Get the appropriate connector class |
7,261 | function configure ( $ config = [ ] ) { $ this -> config = array_replace_recursive ( $ this -> config , $ this -> modes [ @ $ config [ 'mode' ] ? : $ this -> config [ 'mode' ] ] ) ; $ this -> config = array_replace_recursive ( $ this -> config , $ config ) ; return $ this ; } | Set up config values these are merged with the defaults . |
7,262 | public function addField ( $ field ) { $ this -> checkValidLoader ( ) ; if ( ! is_string ( $ field ) ) { throw new GenericException ( 'Must be string!' ) ; } $ this -> loaders [ $ this -> contextLoader ] [ ] = $ field ; return $ this ; } | Add field to context loader |
7,263 | public function setFields ( array $ fields ) { $ this -> checkValidLoader ( ) ; $ this -> loaders [ $ this -> contextLoader ] = [ ] ; $ this -> addFields ( $ fields ) ; return $ this ; } | Set fields to context loader |
7,264 | public function removeField ( $ field ) { $ this -> checkValidLoader ( ) ; if ( in_array ( $ field , $ this -> loaders [ $ this -> contextLoader ] ) ) { array_splice ( $ this -> loaders [ $ this -> contextLoader ] , array_search ( $ field , $ this -> loaders [ $ this -> contextLoader ] ) ) ; } return $ this ; } | Remove field from context loader |
7,265 | public function readdField ( $ field ) { $ this -> checkValidLoader ( ) ; foreach ( $ this -> loaders as $ loader => $ fields ) { if ( in_array ( $ field , $ this -> loaders [ $ loader ] ) ) { array_splice ( $ this -> loaders [ $ loader ] , array_search ( $ field , $ this -> loaders [ $ loader ] ) , 1 ) ; } } $ this ->... | Add field to context loader and remove field from any other loaders |
7,266 | public function getLoaderForField ( $ searchField ) { foreach ( $ this -> loaders as $ loader => $ fields ) { if ( in_array ( $ searchField , $ fields , true ) ) { return $ loader ; } } throw new GenericException ( "Unable to find loader for field \"$searchField\"" ) ; } | Get loader byfield name |
7,267 | public function findRootJobByJobNameAndStatuses ( $ jobName , array $ statuses ) { return $ this -> createJobQueryBuilder ( 'job' ) -> where ( 'job.rootJob is NULL and job.name = :jobName and job.status in (:statuses)' ) -> andWhere ( 'job.interrupted != true' ) -> setParameter ( 'jobName' , $ jobName ) -> setParameter... | Finds root non interrupted job by name and given statuses . |
7,268 | public function getChildJobIdsByRootJobAndStatus ( Job $ rootJob , $ status ) { $ qb = $ this -> createJobQueryBuilder ( 'job' ) ; $ rawChildJobIds = $ qb -> select ( 'job.id' ) -> where ( $ qb -> expr ( ) -> andX ( 'job.rootJob = :rootJob' , 'job.status = :status' ) ) -> setParameters ( new ArrayCollection ( [ new Par... | Be warned that In PGSQL function returns array of ids in DESC order every id has integer type But in MYSQL it will be array of ids in ASC order every id has string type |
7,269 | private function resetEntityManager ( ) { $ managers = $ this -> doctrine -> getManagers ( ) ; foreach ( $ managers as $ name => $ manager ) { if ( ! $ manager -> getMetadataFactory ( ) -> isTransient ( $ this -> entityClass ) ) { $ this -> doctrine -> resetManager ( $ name ) ; break ; } } } | Replaces the closed entity manager with new instance of entity manager . |
7,270 | protected function initTerra ( ) { if ( empty ( $ this -> mapSeed ) ) { $ this -> setMapSeed ( microtime ( true ) ) ; } if ( ! $ this -> getPersistence ( ) ) { throw new LogicException ( 'Persistence must be set' ) ; } if ( ! $ this -> getSize ( ) ) { throw new LogicException ( 'Size must be set' ) ; } mt_srand ( $ thi... | terra array initialization |
7,271 | public function delete ( $ id , $ next ) { $ status = $ this -> handler -> destroy ( $ id ) ; return $ next ( $ id ) && $ status ; } | Delete a session from storage by ID . |
7,272 | public function clean ( $ maxlifetime , $ next ) { $ status = $ this -> handler -> gc ( $ maxlifetime ) ; return $ next ( $ maxlifetime ) && $ status ; } | Clean up all session older than the max lifetime specified . |
7,273 | public function create ( $ path , $ name , $ next ) { $ status = $ this -> handler -> open ( $ path , $ name ) ; return $ next ( $ path , $ name ) && $ status ; } | Create a new session store . |
7,274 | public function read ( $ id , $ next ) { return empty ( $ this -> handler -> read ( $ id ) ) ? $ next ( $ id ) : $ this -> handler -> read ( $ id ) ; } | Read a specific session from storage . |
7,275 | public function fieldValue ( $ field , $ value ) { if ( ! in_array ( $ field , $ this -> supports ) ) { $ this -> supports [ ] = $ field ; } $ this -> values [ $ field ] = $ value ; return $ this ; } | Set field default value |
7,276 | public function includeBooks ( Author $ author , ParamBag $ paramBag = null ) { $ transformer = new BookTransformer ( $ paramBag ) ; $ books = $ author -> books ( ) -> limit ( $ transformer -> getLimit ( ) ) -> offset ( $ transformer -> getOffset ( ) ) -> orderBy ( $ transformer -> getSortKey ( ) , $ transformer -> get... | Include books . |
7,277 | protected function _getSocket ( ) { if ( is_resource ( $ this -> _socket ) ) { if ( feof ( $ this -> _socket ) ) { fclose ( $ this -> _socket ) ; } else { return $ this -> _socket ; } } $ this -> _socket = @ fsockopen ( $ this -> _hostname , $ this -> _port , $ errno , $ errstr , $ this -> _timeout ) ; if ( ! $ this ->... | Get the socket |
7,278 | protected function _doRequest ( $ namespace , $ method , $ args ) { $ authorization = '' ; if ( ! is_null ( $ this -> _username ) && ! is_null ( $ this -> _password ) ) { $ authorization = "\r\nAuthorization: Basic " . base64_encode ( $ this -> _username . ':' . $ this -> _password ) ; } $ xmlRpc = \ xmlrpc_encode_requ... | Do a request to the supervisor XML - RPC API |
7,279 | public function cache ( $ e ) { $ request = $ e -> getRequest ( ) ; if ( $ request instanceof ConsoleRequest || $ request -> getQuery ( ) -> get ( 'EDPSUPERLUMINAL_CACHE' , null ) === null ) { return ; } if ( file_exists ( ZF_CLASS_CACHE ) ) { $ this -> reflectClassCache ( ) ; $ code = file_get_contents ( ZF_CLASS_CACH... | Cache declared interfaces and classes to a single file |
7,280 | static function validate ( $ schema , $ value , $ helper = NULL ) { foreach ( self :: parseConstraints ( $ schema ) as $ c ) { $ constraint = key ( $ c ) ; $ params = $ c [ $ constraint ] ; if ( self :: isBlank ( $ value ) && ! preg_match ( '/require|notblank/i' , $ constraint ) ) continue ; $ value = self :: constrain... | Validate the given values against the constraints given . |
7,281 | static function parseParams ( $ params , $ schema ) { $ params = ( array ) $ params ; foreach ( array_diff_key ( $ schema , [ '_validate' => 1 ] ) as $ k => $ v ) if ( preg_match ( '/^_/' , $ k ) ) $ params [ $ k ] = $ v ; return $ params ; } | Adds extra settings values from the schema as they may be used by the validator as well as other things . |
7,282 | static function constrain ( $ value , $ constraint , $ params = [ ] , $ helper = NULL ) { $ constraint_method = get_called_class ( ) . '::check' . $ constraint ; if ( ! is_callable ( $ constraint_method ) ) throw new \ InvalidArgumentException ( 'Invalid constraint method ' . $ constraint_method . ' called' ) ; return ... | Apply the given constraints with the parameters given . |
7,283 | static function checkThisRequiredWhenThat ( $ value , $ params , $ helper ) { if ( self :: checkPath ( $ params [ 'that' ] , [ 'required' => TRUE , 'in' => ( array ) $ params [ 'is' ] ] , $ helper ) ) { $ params = array_merge ( [ 'message' => 'required when ' . $ params [ 'that' ] . ' in (' . implode ( ', ' , ( array )... | Check field exists based on the value of another field . |
7,284 | static function checkPath ( $ path , $ constraints , $ helper ) { list ( $ where , $ path ) = explode ( ':' , $ path ) ; if ( empty ( $ constraints ) ) $ constraints = [ 'required' => TRUE ] ; foreach ( $ constraints as $ con => $ params ) { if ( $ con === 'required' ) $ constraints [ 'required' ] = $ path ; elseif ( $... | Build a Valitron ruleset from a given path and constraints . |
7,285 | static function fail ( $ value , $ params , $ defaults = [ ] ) { $ params = array_merge ( [ 'message' => 'value is invalid' ] , $ defaults , $ params ) ; $ show_val = is_scalar ( $ value ) ? ' [' . $ value . ']' : '' ; throw new \ RoyalMail \ Exception \ ValidatorException ( $ params [ 'message' ] . $ show_val ) ; } | Handle failed validation constraint . |
7,286 | public function actionIndex ( ) { $ model = new CountryLanguage ( [ 'scenario' => 'search' ] ) ; $ dataProvider = $ model -> search ( Yii :: $ app -> request -> queryParams ) ; return $ this -> render ( 'index' , [ 'model' => $ model , 'dataProvider' => $ dataProvider , ] ) ; } | Lists all CountryLanguage models . |
7,287 | public function actionEdit ( $ id = null ) { if ( $ id === null ) { $ model = new CountryLanguage ; } else { $ model = $ this -> findModel ( $ id ) ; } $ isLoaded = $ model -> load ( Yii :: $ app -> request -> post ( ) ) ; $ hasAccess = ( $ model -> isNewRecord && Yii :: $ app -> user -> can ( 'multilingual-create-coun... | Updates an existing CountryLanguage model . If update is successful the browser will be redirected to the view page . |
7,288 | public function write ( $ id , $ data , $ next ) { $ return = empty ( $ data ) ? $ data : $ this -> encrypt ( $ data ) ; return $ next ( $ id , $ return ) ; } | Encrypt the incoming data payload then pass it along to the next handler in the stack . |
7,289 | public function login ( $ username , $ password , $ appKey , $ deviceId = "" ) { return $ this -> post ( "login" , [ 'username' => $ username , 'password' => $ password , 'applicationKey' => $ appKey , 'deviceId' => $ deviceId ] ) ; } | Login as a given user identified by the provided username and password . |
7,290 | public function hasTranslation ( $ language_id = null , $ checkIsPublished = true ) { $ multilingual = Yii :: $ app -> multilingual ; if ( $ language_id === null ) { $ language_id = $ multilingual -> language_id ; } $ owner = $ this -> owner ; if ( $ language_id === $ multilingual -> language_id ) { $ translation = $ o... | Returns a value indicating whether the translation model for the specified language exists . |
7,291 | public function checkIsPublished ( ActiveRecord $ translationRecord ) { if ( $ this -> translationPublishedAttribute === false ) { return true ; } return $ translationRecord -> getAttribute ( $ this -> translationPublishedAttribute ) == $ this -> translationPublishedAttributeValue ; } | Performs a check of publish state for translation record |
7,292 | public function is_valid ( $ lifetime = null , $ now = null ) { if ( null === $ now ) $ now = time ( ) ; if ( null === $ lifetime ) $ lifetime = ini_get ( 'session.gc_maxlifetime' ) ; return ( int ) $ now - $ this -> _time < ( int ) $ lifetime ; } | Test whether an item is still valid |
7,293 | protected function arrayEquals ( array $ left , $ right ) { if ( ! is_array ( $ right ) ) { return false ; } if ( array_keys ( $ left ) !== array_keys ( $ right ) ) { return false ; } foreach ( $ left as $ key => $ value ) { if ( ! $ this -> valueEquals ( $ value , $ right [ $ key ] ) ) { return false ; } } return true... | Compare an array to another arbitrary value . |
7,294 | protected function objectEquals ( $ left , $ right ) { if ( ! is_object ( $ right ) ) { return false ; } if ( get_class ( $ left ) !== get_class ( $ right ) ) { return false ; } $ stackKey = $ this -> objectComparisonStackKey ( $ left , $ right ) ; if ( array_key_exists ( $ stackKey , $ this -> objectComparisonStack ) ... | Compare an object to another arbitrary value . |
7,295 | protected function objectProperties ( $ object ) { $ properties = array ( ) ; $ reflector = new ReflectionObject ( $ object ) ; while ( $ reflector ) { foreach ( $ reflector -> getProperties ( ) as $ property ) { if ( $ property -> isStatic ( ) ) { continue ; } $ key = sprintf ( '%s::%s' , $ property -> getDeclaringCla... | Get the properties of the supplied object including protected and private values . |
7,296 | protected function objectComparisonStackKey ( $ left , $ right ) { $ ids = array ( spl_object_hash ( $ left ) , spl_object_hash ( $ right ) ) ; sort ( $ ids ) ; return implode ( '.' , $ ids ) ; } | Return a unique key for the current comparison which can be used to avoid recursion issues . |
7,297 | public function getStats ( ) { if ( isset ( $ this -> stats ) ) return $ this -> stats ; $ stats = array ( ) ; $ stats [ 'channels' ] = '1' ; foreach ( explode ( "\n" , $ this -> sox ( '-n' , 'stats' ) ) as $ line ) { if ( empty ( $ line ) || preg_match ( '/^\S+ WARN/' , $ line ) ) continue ; if ( $ line [ 0 ] == ' ' )... | Get statistics of the audio file |
7,298 | private function getStat ( $ stat , $ soxi_arg , $ cast ) { if ( ! isset ( $ this -> $ stat ) ) { $ this -> $ stat = isset ( $ this -> stats ) ? ( float ) $ this -> stats -> $ stat : ( float ) $ this -> soxi ( $ soxi_arg ) ; settype ( $ this -> $ stat , $ cast ) ; } return $ this -> $ stat ; } | Get the a stat of the track |
7,299 | public function combine ( $ method , $ in , $ out ) { if ( $ in instanceof self ) $ in = $ in -> filename ; $ this -> sox ( '--combine' , $ method , $ in , $ out ) ; return new static ( $ out ) ; } | Combine two audio files |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.