idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
12,900
|
public function getCustomer ( ConnectionInterface $ con = null ) { if ( $ this -> aCustomer === null && ( $ this -> customer_id !== null ) ) { $ this -> aCustomer = CustomerQuery :: create ( ) -> findPk ( $ this -> customer_id , $ con ) ; } return $ this -> aCustomer ; }
|
Get the associated ChildCustomer object
|
12,901
|
public function userFollowsChannels ( $ user , $ options = [ ] ) { $ availableOptions = [ 'limit' , 'offset' , 'direction' , 'sortby' ] ; foreach ( $ availableOptions as $ option ) { if ( isset ( $ options [ $ option ] ) ) { $ options [ $ option ] = $ options [ $ option ] ; } } $ url = 'kraken/users/' . $ user . '/follows/channels' ; $ response = $ this -> client -> get ( $ url , [ 'body' => $ options ] ) ; return $ response -> json ( ) ; }
|
Returns a list of follows objects . Parameters Name Required? Type Description limit optional integer Maximum number of objects in array . Default is 25 . Maximum is 100 . offset optional integer Object offset for pagination . Default is 0 . direction optional string Sorting direction . Default is desc . Valid values are asc and desc . sortby optional string Sort key . Default is created_at . Valid values are created_at and last_broadcast .
|
12,902
|
public function destroy ( $ id ) { $ file = $ this -> fileRepo -> getById ( $ id ) ; if ( ! empty ( $ file ) ) { $ this -> authorize ( 'delete' , $ file ) ; $ this -> fileRepo -> delete ( $ file ) ; return $ this -> respondWithSimpleSuccess ( [ 'success' => true ] ) ; } return $ this -> respondNotFound ( ) ; }
|
Remove the specified file from database .
|
12,903
|
public function actionIndex ( ) { $ searchModel = $ this -> module -> manager -> createBlockSearch ( ) ; $ dataProvider = $ searchModel -> search ( $ _GET ) ; return $ this -> render ( 'index' , [ 'dataProvider' => $ dataProvider , 'searchModel' => $ searchModel , ] ) ; }
|
Lists all Block models .
|
12,904
|
public function actionCreate ( ) { $ model = $ this -> module -> manager -> createBlock ( [ 'scenario' => 'create' ] ) ; if ( $ model -> load ( \ Yii :: $ app -> request -> post ( ) ) && $ model -> create ( ) ) { \ Yii :: $ app -> getSession ( ) -> setFlash ( 'block.success' , \ Yii :: t ( 'block' , 'Block has been created' ) ) ; return $ this -> redirect ( [ 'index' ] ) ; } return $ this -> render ( 'create' , [ 'model' => $ model ] ) ; }
|
Creates a new Block model . If creation is successful the browser will be redirected to the index page .
|
12,905
|
public function actionUpdate ( $ id ) { $ model = $ this -> findModel ( $ id ) ; $ model -> scenario = 'update' ; if ( $ model -> load ( \ Yii :: $ app -> request -> post ( ) ) && $ model -> save ( ) ) { if ( \ Yii :: $ app -> request -> get ( 'returnUrl' ) ) { $ back = urldecode ( \ Yii :: $ app -> request -> get ( 'returnUrl' ) ) ; return $ this -> redirect ( $ back ) ; } \ Yii :: $ app -> getSession ( ) -> setFlash ( 'block.success' , \ Yii :: t ( 'block' , 'Block has been updated' ) ) ; return $ this -> refresh ( ) ; } return $ this -> render ( 'update' , [ 'model' => $ model ] ) ; }
|
Updates an existing Block model . If update is successful the browser will be redirected to the index page .
|
12,906
|
function array_sum_interval ( $ array_external , $ interval ) { $ n_interval = explode ( ":" , $ interval ) ; $ sum = 0 ; for ( $ i = $ n_interval [ 0 ] ; $ i < ( $ n_interval [ 1 ] + 1 ) ; $ i ++ ) { $ sum += $ array_external [ $ i ] ; } return $ sum ; }
|
Function for sum intervals of an array
|
12,907
|
function array_sum_intervals ( $ array_external , $ intervals ) { $ n_intervals = explode ( ";" , $ intervals ) ; $ array_amount = count ( $ n_intervals ) ; $ result = 0 ; for ( $ i = 0 ; $ i < $ array_amount ; $ i ++ ) { $ result += $ this -> array_sum_interval ( $ array_external , $ n_intervals [ $ i ] ) ; } return $ result ; }
|
Function for sum a interval of an array
|
12,908
|
function flipDiagonally ( $ arr ) { $ out = array ( ) ; foreach ( $ arr as $ key => $ subarr ) { foreach ( $ subarr as $ subkey => $ subvalue ) { $ out [ $ subkey ] [ $ key ] = $ subvalue ; } } return $ out ; }
|
Matriz Transposta - transforma array dados de linhas em colunas
|
12,909
|
function ImagePngWithAlpha ( $ file , $ x , $ y , $ w = 0 , $ h = 0 , $ link = '' ) { $ tmp_alpha = tempnam ( '.' , 'mska' ) ; $ this -> tmpFiles [ ] = $ tmp_alpha ; $ tmp_plain = tempnam ( '.' , 'mskp' ) ; $ this -> tmpFiles [ ] = $ tmp_plain ; list ( $ wpx , $ hpx ) = getimagesize ( $ file ) ; $ img = imagecreatefrompng ( $ file ) ; $ alpha_img = imagecreate ( $ wpx , $ hpx ) ; for ( $ c = 0 ; $ c < 256 ; $ c ++ ) ImageColorAllocate ( $ alpha_img , $ c , $ c , $ c ) ; $ xpx = 0 ; while ( $ xpx < $ wpx ) { $ ypx = 0 ; while ( $ ypx < $ hpx ) { $ color_index = imagecolorat ( $ img , $ xpx , $ ypx ) ; $ alpha = 255 - ( $ color_index >> 24 ) * 255 / 127 ; imagesetpixel ( $ alpha_img , $ xpx , $ ypx , $ alpha ) ; ++ $ ypx ; } ++ $ xpx ; } imagepng ( $ alpha_img , $ tmp_alpha ) ; imagedestroy ( $ alpha_img ) ; $ plain_img = imagecreatetruecolor ( $ wpx , $ hpx ) ; imagecopy ( $ plain_img , $ img , 0 , 0 , 0 , 0 , $ wpx , $ hpx ) ; imagepng ( $ plain_img , $ tmp_plain ) ; imagedestroy ( $ plain_img ) ; $ maskImg = $ this -> Image ( $ tmp_alpha , 0 , 0 , 0 , 0 , 'PNG' , '' , true ) ; $ this -> Image ( $ tmp_plain , $ x , $ y , $ w , $ h , 'PNG' , $ link , false , $ maskImg ) ; }
|
pixel - wise operation not very fast
|
12,910
|
public function extend ( IHttpResponse $ response ) { $ this -> setHeaders ( clone ( $ response -> getHeaders ( ) ) ) ; $ this -> setProtocol ( $ response -> getProtocol ( ) ) ; $ this -> setProtocolVersion ( $ response -> getProtocolVersion ( ) ) ; $ this -> setStatusCode ( $ response -> getStatusCode ( ) ) ; $ this -> setContent ( $ response -> getContent ( ) ) ; $ this -> setCookies ( clone ( $ response -> getCookies ( ) ) ) ; $ this -> setDefaultContentType ( ) ; }
|
Extend current response with another .
|
12,911
|
public function searchStreams ( $ query , $ params = [ ] ) { $ defaults = [ 'query' => urlencode ( $ query ) , 'limit' => 25 , 'offset' => 0 , 'hls' => null , ] ; return $ this -> wrapper -> request ( 'GET' , 'search/streams' , [ 'query' => $ this -> resolveOptions ( $ params , $ defaults ) ] ) ; }
|
Returns a list of stream objects matching the search query .
|
12,912
|
public function searchGames ( $ query , $ params = [ ] ) { $ defaults = [ 'query' => urlencode ( $ query ) , 'limit' => 25 , 'type' => 'suggest' , 'live' => false , ] ; return $ this -> wrapper -> request ( 'GET' , 'search/games' , [ 'query' => $ this -> resolveOptions ( $ params , $ defaults ) ] ) ; }
|
Returns a list of game objects matching the search query .
|
12,913
|
private function open ( ) { if ( file_exists ( $ this -> target ) && ! unlink ( $ this -> target ) ) throw new ZipExporterException ( "could not remove existing zip archive at \"$this->target\"" ) ; $ zip = new \ ZipArchive ( ) ; if ( ! $ zip -> open ( $ this -> target , \ ZipArchive :: CREATE ) ) throw new ZipExporterException ( "could not create zip archive at \"$this->target\"" ) ; return $ zip ; }
|
Opens and returns the targeted ZIP archive .
|
12,914
|
public function export ( $ product ) { $ productLineName = $ product -> getProductLine ( ) -> getName ( ) ; $ files = $ product -> generateFiles ( ) ; $ zip = $ this -> open ( ) ; if ( count ( $ files ) === 0 ) $ files [ ] = new fphp \ File \ TextFile ( "NOTICE" , "No files were generated." ) ; foreach ( $ files as $ file ) if ( ! $ file -> getContent ( ) -> addToZip ( $ zip , fphp \ Helper \ Path :: join ( $ productLineName , $ file -> getTarget ( ) ) ) ) throw new ZipExporterException ( "could not add file to zip archive at \"$this->target\"" ) ; $ this -> close ( $ zip ) ; }
|
Exports a product as a ZIP archive . Every generated file is added to the archive at its target path . If there are no files a NOTICE file is generated because \ ZipArchive does not support saving an empty ZIP archive . The archive s root directory has the product line s name .
|
12,915
|
public function addPsr0 ( $ prefix , $ base_dir , $ prepend = false ) { $ prefix = trim ( $ prefix , '\\' ) . '\\' ; $ base_dir = rtrim ( $ base_dir , self :: DS ) . self :: DS ; if ( isset ( $ this -> autoloadersPsr0 [ $ prefix ] ) === false ) { $ this -> autoloadersPsr0 [ $ prefix ] = array ( ) ; } if ( $ prepend ) { array_unshift ( $ this -> autoloadersPsr0 [ $ prefix ] , $ base_dir ) ; } else { array_push ( $ this -> autoloadersPsr0 [ $ prefix ] , $ base_dir ) ; } return $ this ; }
|
Psr - 0
|
12,916
|
public function addNamespace ( $ prefix , $ base_dir , $ prepend = false ) { return $ this -> addPsr4 ( $ prefix , $ base_dir , $ prepend ) ; }
|
Psr - 4
|
12,917
|
protected function addMethods ( $ methods , $ traitDescriptor ) { foreach ( $ methods as $ method ) { $ methodDescriptor = $ this -> getBuilder ( ) -> buildDescriptor ( $ method ) ; if ( $ methodDescriptor ) { $ methodDescriptor -> setParent ( $ traitDescriptor ) ; $ traitDescriptor -> getMethods ( ) -> set ( $ methodDescriptor -> getName ( ) , $ methodDescriptor ) ; } } }
|
Registers the child methods with the generated Trait Descriptor .
|
12,918
|
public function getOrFind ( $ id , $ published = true ) { $ node = $ this -> get ( $ id ) ; if ( is_null ( $ node ) ) { $ node = $ published ? PublishedNode :: find ( $ id ) : Node :: find ( $ id ) ; $ this -> put ( $ id , $ node ) ; } return $ node ; }
|
Gets or finds the node and sets by id
|
12,919
|
public function get ( $ id , $ ignore_cache = false ) { if ( empty ( $ this -> primary_key ) ) { return null ; } $ row = $ this -> where ( "{$this->table}.{$this->primary_key} = %d" , $ id ) -> get_row ( '' , $ ignore_cache ) ; if ( $ row && $ this -> result_class ) { return new $ this -> result_class ( $ row ) ; } else { return $ row ; } }
|
Get object with primary key
|
12,920
|
public function get_col ( $ x = 0 , $ query = '' ) { if ( ! $ query ) { $ query = $ this -> build_query ( ) ; } $ this -> clear ( ) ; return $ this -> db -> get_col ( $ query , $ x ) ; }
|
Returns specified column as array
|
12,921
|
public function get_row ( $ query = '' , $ ignore_cache = false ) { if ( empty ( $ query ) ) { $ query = $ this -> build_query ( ) ; $ this -> clear ( ) ; } if ( $ this -> cache_exist ( $ query ) && ! $ ignore_cache ) { return $ this -> get_cache ( $ query ) ; } else { return $ this -> db -> get_row ( $ query ) ; } }
|
Returns row object
|
12,922
|
public function getList ( array $ hasFeatures = array ( ) ) { $ params = array ( ) ; if ( ! empty ( $ hasFeatures ) ) { $ params [ 'features' ] = json_encode ( array_values ( $ hasFeatures ) ) ; } return $ this -> post ( 'clients/list' , $ params ) ; }
|
Since list is reserved keyword in PHP .
|
12,923
|
public function setDescription ( $ clientId , $ description ) { $ params = array ( 'for_client_id' => $ clientId , 'description' => $ description , ) ; if ( ! $ params [ 'for_client_id' ] ) { unset ( $ params [ 'for_client_id' ] ) ; } return $ this -> post ( 'clients/set_description' , $ params ) ; }
|
Change the description of a client . This can also be thought of as the name of the client . This API call may only be made by the owner client .
|
12,924
|
public function setFeatures ( $ clientId , array $ features ) { $ params = array ( 'for_client_id' => $ clientId , 'features' => json_encode ( $ features ) , ) ; if ( ! $ params [ 'for_client_id' ] ) { unset ( $ params [ 'for_client_id' ] ) ; } return $ this -> post ( 'clients/set_features' , $ params ) ; }
|
Change the features that a target client has by overwriting the old feature list . This API call may only be made by the owner client . The owner client may not remove the owner feature from itself .
|
12,925
|
public function setWhiteList ( $ clientId , array $ addresses ) { $ params = array ( 'for_client_id' => $ clientId , 'whitelist' => json_encode ( $ addresses ) , ) ; if ( ! $ params [ 'for_client_id' ] ) { unset ( $ params [ 'for_client_id' ] ) ; } return $ this -> post ( 'clients/set_whitelist' , $ params ) ; }
|
Change the IP whitelist for a target client overwriting the previous whitelist .
|
12,926
|
public function connectOutputToLogging ( OutputInterface $ output , $ command ) { static $ alreadyConnected = false ; $ helper = $ this ; if ( $ alreadyConnected ) { return ; } $ eventDispatcher = $ command -> getService ( 'event_dispatcher' ) ; $ eventDispatcher -> addListener ( 'parser.file.pre' , function ( PreFileEvent $ event ) use ( $ output ) { $ output -> writeln ( 'Parsing <info>' . $ event -> getFile ( ) . '</info>' ) ; } ) ; $ eventDispatcher -> addListener ( 'system.log' , function ( LogEvent $ event ) use ( $ command , $ helper , $ output ) { $ helper -> logEvent ( $ output , $ event , $ command ) ; } ) ; $ alreadyConnected = true ; }
|
Connect the logging events to the output object of Symfony Console .
|
12,927
|
public function logEvent ( OutputInterface $ output , LogEvent $ event , Command $ command ) { $ numericErrors = array ( LogLevel :: DEBUG => 0 , LogLevel :: NOTICE => 1 , LogLevel :: INFO => 2 , LogLevel :: WARNING => 3 , LogLevel :: ERROR => 4 , LogLevel :: ALERT => 5 , LogLevel :: CRITICAL => 6 , LogLevel :: EMERGENCY => 7 , ) ; $ threshold = LogLevel :: ERROR ; if ( $ output -> getVerbosity ( ) === OutputInterface :: VERBOSITY_DEBUG ) { $ threshold = LogLevel :: DEBUG ; } if ( $ numericErrors [ $ event -> getPriority ( ) ] >= $ numericErrors [ $ threshold ] ) { $ translator = $ command -> getContainer ( ) -> offsetGet ( 'translator' ) ; $ message = vsprintf ( $ translator -> translate ( $ event -> getMessage ( ) ) , $ event -> getContext ( ) ) ; switch ( $ event -> getPriority ( ) ) { case LogLevel :: WARNING : $ message = '<comment>' . $ message . '</comment>' ; break ; case LogLevel :: EMERGENCY : case LogLevel :: ALERT : case LogLevel :: CRITICAL : case LogLevel :: ERROR : $ message = '<error>' . $ message . '</error>' ; break ; } $ output -> writeln ( ' ' . $ message ) ; } }
|
Logs an event with the output .
|
12,928
|
public function put ( $ url , array $ data = [ ] , array $ headers = [ ] ) { $ this -> unsetOptions ( [ CURLOPT_HTTPGET , CURLOPT_POST ] ) ; $ this -> setOption ( CURLOPT_CUSTOMREQUEST , 'PUT' ) ; return $ this -> send ( $ url , $ data , $ headers ) ; }
|
Send PUT request
|
12,929
|
private function setDefaultOptions ( ) { $ this -> setOptions ( [ CURLOPT_SSL_VERIFYPEER => true , CURLOPT_HEADER => false , CURLOPT_RETURNTRANSFER => true , CURLOPT_FAILONERROR => false ] ) ; }
|
Set default cURL options
|
12,930
|
private function setData ( array $ data ) { if ( ! empty ( $ data ) ) { $ this -> setOption ( CURLOPT_POSTFIELDS , $ this -> optionParser -> parseData ( $ data ) ) ; } else { $ this -> unsetOption ( CURLOPT_POSTFIELDS ) ; } }
|
Set request post fields
|
12,931
|
private function setHeaders ( array $ headers ) { if ( ! empty ( $ headers ) ) { $ this -> setOption ( CURLOPT_HTTPHEADER , $ this -> optionParser -> parseHeaders ( $ headers ) ) ; } else { $ this -> unsetOption ( CURLOPT_HTTPHEADER ) ; } }
|
Set request headers
|
12,932
|
public function get ( $ url , $ query = [ ] , $ headers = [ ] ) { $ headers = array_merge ( $ this -> global_headers , $ headers ) ; return $ this -> request ( 'GET' , $ url , [ ] , $ query , $ headers ) ; }
|
Special method for GET because we never pass in a body .
|
12,933
|
public function request ( $ method , $ url , $ body = [ ] , $ query = [ ] , $ headers = [ ] ) { list ( $ body , $ query , $ headers ) = $ this -> setupVariables ( $ body , $ query , $ headers ) ; if ( ! empty ( $ body ) ) { $ body = encode ( $ body ) ; $ headers [ 'Content-Type' ] = 'application/json' ; } else { $ body = null ; } $ headers = array_merge ( $ this -> global_headers , $ headers ) ; try { $ response = $ this -> client -> request ( $ method , $ url , [ 'query' => $ query , 'body' => $ body , 'headers' => $ headers , ] ) ; $ response_body = ( string ) $ response -> getBody ( ) ; } catch ( BadResponseException $ exception ) { self :: handleError ( $ exception ) ; } switch ( $ this -> mode ) { case - 1 : return $ response ; case 0 : return $ response_body ; case 1 : if ( ! empty ( $ response_body ) ) { return decode ( $ response_body ) ; } return ; case 2 : if ( ! empty ( $ response_body ) ) { return CollectionManager :: build ( decode ( $ response_body ) ) ; } return ; default : throw new JSONLibraryException ( 'unknown_mode_set' ) ; } }
|
The main meaty request method handles all outgoing requests and deals with responses .
|
12,934
|
public function requestAsync ( $ method , $ url , $ body = [ ] , $ query = [ ] , $ headers = [ ] ) { if ( ! empty ( $ body ) ) { $ body = encode ( $ body ) ; $ headers [ 'Content-Type' ] = 'application/json' ; } else { $ body = null ; } $ headers = array_merge ( $ this -> global_headers , $ headers ) ; return $ this -> client -> requestAsync ( $ method , $ url , [ 'query' => $ query , 'body' => $ body , 'headers' => $ headers , ] ) ; }
|
Return a promise for async requests .
|
12,935
|
public static function handleError ( BadResponseException $ exception ) { $ response_body = ( string ) $ exception -> getResponse ( ) -> getBody ( ) ; $ array_body = decode ( $ response_body ) ; $ code = $ exception -> getResponse ( ) -> getStatusCode ( ) ; $ lookForKeys = [ 'message' , 'code' , 'error' ] ; foreach ( $ lookForKeys as $ key ) { if ( isset ( $ array_body [ $ key ] ) ) { $ message = $ array_body [ $ key ] ; } } if ( ! $ message ) { $ message = 'unknown_error' ; } throw new JSONError ( $ message , $ code , $ array_body ) ; }
|
Handles the error for us just a bit of code abstraction .
|
12,936
|
public function mode ( $ mode ) { $ acceptable_modes = [ - 1 , 0 , 1 , 2 ] ; if ( ! in_array ( $ mode , $ acceptable_modes ) ) { throw new JSONLibraryException ( 'bad_mode_set' ) ; } $ this -> mode = $ mode ; return $ this ; }
|
Set the mode fluently .
|
12,937
|
private function setupVariables ( $ body , $ query , $ headers ) { if ( is_null ( $ headers ) ) { $ headers = [ ] ; } if ( is_null ( $ query ) ) { $ query = [ ] ; } if ( is_null ( $ body ) ) { $ body = [ ] ; } return [ $ body , $ query , $ headers ] ; }
|
Setup empty arrays if null given .
|
12,938
|
public function initialize ( ) { $ vendorPath = $ this -> findVendorPath ( ) ; $ autoloader = $ this -> createAutoloader ( $ vendorPath ) ; return new Application ( $ autoloader , array ( 'composer.vendor_path' => $ vendorPath ) ) ; }
|
Convenience method that does the complete initialization for phpDocumentor .
|
12,939
|
public function registerProfiler ( ) { $ profile = ( bool ) ( getenv ( 'PHPDOC_PROFILE' ) === 'on' ) ; $ xhguiPath = getenv ( 'XHGUI_PATH' ) ; if ( $ profile && $ xhguiPath && extension_loaded ( 'xhprof' ) ) { echo 'PROFILING ENABLED' . PHP_EOL ; include ( $ xhguiPath . '/external/header.php' ) ; } return $ this ; }
|
Sets up XHProf so that we can profile phpDocumentor using XHGUI .
|
12,940
|
public function createAutoloader ( $ vendorDir = null ) { if ( ! $ vendorDir ) { $ vendorDir = __DIR__ . '/../../vendor' ; } $ autoloader_location = $ vendorDir . '/autoload.php' ; if ( ! file_exists ( $ autoloader_location ) || ! is_readable ( $ autoloader_location ) ) { throw new \ RuntimeException ( 'phpDocumentor expected to find an autoloader at "' . $ autoloader_location . '" but it was not there. ' . 'Usually this is because the "composer install" command has not been ran yet. If this is not the ' . 'case, please open an issue at http://github.com/phpDocumentor/phpDocumentor2 detailing what ' . 'installation method you used, which path is mentioned in this error message and any other relevant ' . 'information.' ) ; } return require $ autoloader_location ; }
|
Initializes and returns the autoloader .
|
12,941
|
public function collectConsole ( ) { if ( ! $ this -> isEnabled ( ) ) { return ; } $ this -> meta = [ 'time' => microtime ( true ) , 'method' => 'CLI' , 'uri' => isset ( $ _SERVER [ 'argv' ] ) ? implode ( ' ' , $ _SERVER [ 'argv' ] ) : null , 'ip' => isset ( $ _SERVER [ 'SSH_CLIENT' ] ) ? $ _SERVER [ 'SSH_CLIENT' ] : null , ] ; foreach ( $ this -> collectors as $ name => $ collector ) { $ this -> data [ $ name ] = $ collector -> collect ( ) ; } array_walk_recursive ( $ this -> data , function ( & $ item ) { if ( is_string ( $ item ) && ! mb_check_encoding ( $ item , 'UTF-8' ) ) { $ item = mb_convert_encoding ( $ item , 'UTF-8' , 'UTF-8' ) ; } } ) ; $ this -> persistData ( ) ; return $ this -> data ; }
|
Collect data in a CLI request
|
12,942
|
public function json ( $ status_code , $ message , $ data = null ) { return response ( ) -> json ( [ 'status_code' => $ status_code , 'message' => $ message , 'data' => $ data , 'request' => \ request ( ) -> all ( ) , ] ) ; }
|
Basic Json method .
|
12,943
|
protected function parseNamespaces ( ClassMetadata $ metadata , $ config ) { if ( ! isset ( $ config [ 'namespaces' ] ) ) { return ; } if ( ! is_array ( $ config ) ) { throw new \ RuntimeException ( sprintf ( 'Invalid YAML configuration for "%s" : "namespaces" property need to be an array.' , $ metadata -> name ) ) ; } foreach ( $ config [ 'namespaces' ] as $ prefix => $ uri ) { $ metadata -> addGraphNamespace ( new NamespaceNode ( [ 'prefix' => $ prefix , 'uri' => $ uri , ] ) ) ; } }
|
Parse namespaces configuration
|
12,944
|
protected function parseNodes ( \ ReflectionClass $ class , ClassMetadata $ metadata , $ config ) { if ( ! isset ( $ config [ 'nodes' ] ) ) { return ; } if ( ! is_array ( $ config ) ) { throw new \ RuntimeException ( sprintf ( 'Invalid YAML configuration for "%s" : "properties" property need to be an array.' , $ metadata -> name ) ) ; } foreach ( $ config [ 'nodes' ] as $ property => $ nodeProperties ) { foreach ( $ nodeProperties as $ nodeProperty ) { if ( ! isset ( $ nodeProperty [ 'namespace' ] ) || ! isset ( $ nodeProperty [ 'tag' ] ) ) { throw new \ RuntimeException ( sprintf ( 'Invalid YAML configuration for "%s" : "namespace" and "tag" are required.' , $ metadata -> name ) ) ; } $ node = new Node ( [ 'namespace' => $ nodeProperty [ 'namespace' ] , 'tag' => $ nodeProperty [ 'tag' ] , ] ) ; if ( $ class -> hasProperty ( $ property ) ) { $ metadata -> addGraphMetadata ( $ node , new PropertyMetadata ( $ class -> name , $ property ) ) ; } if ( $ class -> hasMethod ( $ property ) ) { $ metadata -> addGraphMetadata ( $ node , new MethodMetadata ( $ class -> name , $ property ) ) ; } } } }
|
Parse OpenGraph node properties
|
12,945
|
static public function getApps ( ) { static $ applications = array ( ) ; if ( ! empty ( $ applications ) ) { return $ applications ; } $ appsDir = APP_ROOT_DIR . '/Application' ; $ content = scandir ( $ appsDir ) ; foreach ( $ content as $ item ) { if ( is_dir ( $ appsDir . '/' . $ item ) && $ item != '.' && $ item != '..' ) { $ application = array ( ) ; $ application [ 'name' ] = $ item ; $ application [ 'path' ] = $ appsDir . '/' . $ item ; $ applications [ $ item ] = $ application ; } } $ application = array ( ) ; $ application [ 'name' ] = basename ( APP_FW_DIR ) ; $ application [ 'path' ] = APP_FW_DIR ; $ applications [ 'Towel' ] = $ application ; return $ applications ; }
|
Gets Available applications
|
12,946
|
protected function setShortcodeAttribute ( $ value ) { $ shortcode = Utilities :: extractNumerics ( $ value ) ; if ( substr ( $ shortcode , 0 , 5 ) != '29290' ) { throw new InvalidConfig ( 'Shortcode must start with `29290`. `' . $ shortcode . '` is given' ) ; } return $ shortcode ; }
|
When setting shortcode
|
12,947
|
public function nextVerse ( ) { if ( $ this -> isEmpty ( ) ) throw new Exception ( __METHOD__ . ': Can\'t find next - current passage is invalid.' ) ; $ oLastVerse = $ this -> getLastVerse ( ) ; return $ this -> oBible -> nextVerse ( $ oLastVerse -> book_id , $ oLastVerse -> chapter , $ oLastVerse -> verse ) ; }
|
Return the next Bible verse after the current passage .
|
12,948
|
public function run ( JobInterface $ job ) { parent :: run ( $ job ) ; if ( ! ( $ job instanceof MappedJob ) ) { return $ this ; } $ job -> setResult ( $ this -> mapper -> map ( $ job -> getEntityRepository ( ) , $ job -> getMappedClass ( ) , $ job -> getResult ( ) ) ) ; return $ this ; }
|
runs the parent job and then maps the result
|
12,949
|
protected function discover ( ) { foreach ( $ this -> fileset as $ file ) { $ rst = new Document ( $ this , $ file ) ; $ rst -> options -> xhtmlVisitor = 'phpDocumentor\Plugin\Scrybe\Converter\RestructuredText\Visitors\Discover' ; if ( $ this -> getLogger ( ) ) { $ this -> getLogger ( ) -> info ( 'Scanning file "' . $ file -> getRealPath ( ) . '"' ) ; } try { $ rst -> getAsXhtml ( ) ; } catch ( \ Exception $ e ) { continue ; } } }
|
Discovers the data that is spanning all files .
|
12,950
|
protected function create ( TemplateInterface $ template ) { $ result = array ( ) ; foreach ( $ this -> fileset as $ file ) { $ rst = new Document ( $ this , $ file ) ; $ destination = $ this -> getDestinationFilenameRelativeToProjectRoot ( $ file ) ; $ this -> setDestinationRoot ( $ destination ) ; if ( $ this -> getLogger ( ) ) { $ this -> getLogger ( ) -> info ( 'Parsing file "' . $ file -> getRealPath ( ) . '"' ) ; } try { $ xhtml_document = $ rst -> getAsXhtml ( ) ; $ converted_contents = $ template -> decorate ( $ xhtml_document -> save ( ) , $ this -> options ) ; $ rst -> logStats ( null , $ this -> getLogger ( ) ) ; } catch ( \ Exception $ e ) { $ rst -> logStats ( $ e , $ this -> getLogger ( ) ) ; continue ; } $ result [ $ destination ] = $ converted_contents ; } return $ result ; }
|
Converts the input files into one or more output files in the intended format .
|
12,951
|
protected function setDestinationRoot ( $ destination ) { $ this -> options [ 'root' ] = dirname ( $ destination ) != '.' ? implode ( '/' , array_fill ( 0 , count ( explode ( '/' , dirname ( $ destination ) ) ) , '..' ) ) . '/' : './' ; }
|
Sets the relative path to the root of the generated contents .
|
12,952
|
public function setAttribute ( string $ key , string $ value ) { if ( $ this -> valid ( $ key , $ value ) ) { $ value = encrypt ( $ value ) ; } return parent :: setAttribute ( $ key , $ value ) ; }
|
Encrypt field value before inserting into database
|
12,953
|
public function getAttribute ( string $ key ) { $ value = parent :: getAttribute ( $ key ) ; if ( $ this -> valid ( $ key , $ value ) ) { return decrypt ( $ value ) ; } return $ value ; }
|
Get decrypted field values after getting from database
|
12,954
|
public function attributesToArray ( ) { $ attributes = parent :: attributesToArray ( ) ; foreach ( $ attributes as $ key => $ value ) { if ( $ this -> valid ( $ key , $ value ) ) { $ attributes [ $ key ] = decrypt ( $ value ) ; } } return $ attributes ; }
|
Decrypt given attributes
|
12,955
|
protected function valid ( string $ key , string $ value ) { return in_array ( $ key , $ this -> encryptable ) && ! is_null ( $ value ) && ! empty ( $ value ) ; }
|
Check if key and value is valid and able to crypt or decrypt
|
12,956
|
public function register_cron ( ) { if ( ! wp_next_scheduled ( $ this -> event ) ) { wp_schedule_event ( $ this -> start_at ( ) , $ this -> schedule , $ this -> event , $ this -> args ( ) ) ; } add_action ( $ this -> event , [ $ this , 'process' ] ) ; }
|
Register cron event
|
12,957
|
private static function getPhpEncoding ( $ html_charset ) { $ php_encoding = null ; switch ( strtolower ( $ html_charset ) ) { case 'sjis' : case 'sjis-win' : case 'shift_jis' : case 'shift-jis' : case 'ms_kanji' : case 'csshiftjis' : case 'x-sjis' : $ php_encoding = 'sjis-win' ; break ; case 'euc-jp' : case 'cseucpkdfmtjapanese' : $ php_encoding = 'EUC-JP' ; break ; case 'jis' : $ php_encoding = 'jis' ; break ; case 'iso-2022-jp' : case 'csiso2022jp' : $ php_encoding = 'ISO-2022-JP' ; break ; case 'iso-2022-jp-2' : case 'csiso2022jp2' : $ php_encoding = 'ISO-2022-JP-2' ; break ; case 'utf-8' : case 'csutf8' : $ php_encoding = 'UTF-8' ; break ; case 'utf-16' : case 'csutf16' : $ php_encoding = 'UTF-16' ; break ; default : if ( strpos ( $ html_charset , 'sjis' ) ) { $ php_encoding = 'SJIS' ; } break ; } return $ php_encoding ; }
|
Get PHP character encoding
|
12,958
|
public function getLocalReferer ( ) { $ request = $ this -> getRequest ( ) ; $ referer = $ request -> getHeaderLine ( 'HTTP_REFERER' ) ; $ host = $ request -> getHeaderLine ( 'HTTP_HOST' ) ; return $ referer && parse_url ( $ referer , PHP_URL_HOST ) === $ host ? $ referer : '' ; }
|
Returns the HTTP referer if it is on the current host
|
12,959
|
public function getApplication ( ) { if ( ! is_object ( $ this -> application ) ) { $ this -> application = Application :: init ( ) ; } return $ this -> application ; }
|
Get Yawik Application to use
|
12,960
|
public function analyze ( ProjectDescriptor $ projectDescriptor ) { $ this -> unresolvedParentClassesCount = 0 ; $ elementCounter = array ( ) ; foreach ( $ this -> findAllElements ( $ projectDescriptor ) as $ element ) { $ elementCounter = $ this -> addElementToCounter ( $ elementCounter , $ element ) ; $ this -> incrementUnresolvedParentCounter ( $ element ) ; } $ this -> descriptorCountByType = $ elementCounter ; $ this -> fileCount = count ( $ projectDescriptor -> getFiles ( ) ) ; $ this -> topLevelNamespaceCount = count ( $ projectDescriptor -> getNamespace ( ) -> getChildren ( ) ) ; }
|
Analyzes the given project descriptor and populates this object s properties .
|
12,961
|
protected function addElementToCounter ( $ classCounters , $ element ) { if ( ! isset ( $ classCounters [ get_class ( $ element ) ] ) ) { $ classCounters [ get_class ( $ element ) ] = 0 ; } $ classCounters [ get_class ( $ element ) ] ++ ; return $ classCounters ; }
|
Increments the counter for element s class in the class counters .
|
12,962
|
public static function item ( $ property , $ code , $ byId = false ) { $ property_id = self :: getPropertyId ( $ property , $ byId ) ; if ( ! isset ( self :: $ _items [ $ property_id ] ) ) self :: loadItems ( $ property_id ) ; return isset ( self :: $ _items [ $ property_id ] [ $ code ] ) ? self :: $ _items [ $ property_id ] [ $ code ] : false ; }
|
Returns the item name for the specified property and code .
|
12,963
|
private static function loadItems ( $ property_id ) { self :: $ _items [ $ property_id ] = [ ] ; $ models = static :: find ( ) -> where ( 'property_id=:property_id' , [ ':property_id' => $ property_id ] ) -> orderBy ( 'position' ) -> all ( ) ; foreach ( $ models as $ model ) self :: $ _items [ $ property_id ] [ $ model -> code ] = $ model -> name ; }
|
Loads the lookup items for the specified property ID .
|
12,964
|
public function initCustomerCustomerGroups ( $ overrideExisting = true ) { if ( null !== $ this -> collCustomerCustomerGroups && ! $ overrideExisting ) { return ; } $ this -> collCustomerCustomerGroups = new ObjectCollection ( ) ; $ this -> collCustomerCustomerGroups -> setModel ( '\CustomerGroup\Model\CustomerCustomerGroup' ) ; }
|
Initializes the collCustomerCustomerGroups collection .
|
12,965
|
public function getCustomerCustomerGroups ( $ criteria = null , ConnectionInterface $ con = null ) { $ partial = $ this -> collCustomerCustomerGroupsPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collCustomerCustomerGroups || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collCustomerCustomerGroups ) { $ this -> initCustomerCustomerGroups ( ) ; } else { $ collCustomerCustomerGroups = ChildCustomerCustomerGroupQuery :: create ( null , $ criteria ) -> filterByCustomerGroup ( $ this ) -> find ( $ con ) ; if ( null !== $ criteria ) { if ( false !== $ this -> collCustomerCustomerGroupsPartial && count ( $ collCustomerCustomerGroups ) ) { $ this -> initCustomerCustomerGroups ( false ) ; foreach ( $ collCustomerCustomerGroups as $ obj ) { if ( false == $ this -> collCustomerCustomerGroups -> contains ( $ obj ) ) { $ this -> collCustomerCustomerGroups -> append ( $ obj ) ; } } $ this -> collCustomerCustomerGroupsPartial = true ; } reset ( $ collCustomerCustomerGroups ) ; return $ collCustomerCustomerGroups ; } if ( $ partial && $ this -> collCustomerCustomerGroups ) { foreach ( $ this -> collCustomerCustomerGroups as $ obj ) { if ( $ obj -> isNew ( ) ) { $ collCustomerCustomerGroups [ ] = $ obj ; } } } $ this -> collCustomerCustomerGroups = $ collCustomerCustomerGroups ; $ this -> collCustomerCustomerGroupsPartial = false ; } } return $ this -> collCustomerCustomerGroups ; }
|
Gets an array of ChildCustomerCustomerGroup objects which contain a foreign key that references this object .
|
12,966
|
public function countCustomerCustomerGroups ( Criteria $ criteria = null , $ distinct = false , ConnectionInterface $ con = null ) { $ partial = $ this -> collCustomerCustomerGroupsPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collCustomerCustomerGroups || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collCustomerCustomerGroups ) { return 0 ; } if ( $ partial && ! $ criteria ) { return count ( $ this -> getCustomerCustomerGroups ( ) ) ; } $ query = ChildCustomerCustomerGroupQuery :: create ( null , $ criteria ) ; if ( $ distinct ) { $ query -> distinct ( ) ; } return $ query -> filterByCustomerGroup ( $ this ) -> count ( $ con ) ; } return count ( $ this -> collCustomerCustomerGroups ) ; }
|
Returns the number of related CustomerCustomerGroup objects .
|
12,967
|
public function addCustomerCustomerGroup ( ChildCustomerCustomerGroup $ l ) { if ( $ this -> collCustomerCustomerGroups === null ) { $ this -> initCustomerCustomerGroups ( ) ; $ this -> collCustomerCustomerGroupsPartial = true ; } if ( ! in_array ( $ l , $ this -> collCustomerCustomerGroups -> getArrayCopy ( ) , true ) ) { $ this -> doAddCustomerCustomerGroup ( $ l ) ; } return $ this ; }
|
Method called to associate a ChildCustomerCustomerGroup object to this object through the ChildCustomerCustomerGroup foreign key attribute .
|
12,968
|
public function getCustomerCustomerGroupsJoinCustomer ( $ criteria = null , $ con = null , $ joinBehavior = Criteria :: LEFT_JOIN ) { $ query = ChildCustomerCustomerGroupQuery :: create ( null , $ criteria ) ; $ query -> joinWith ( 'Customer' , $ joinBehavior ) ; return $ this -> getCustomerCustomerGroups ( $ query , $ con ) ; }
|
If this collection has already been initialized with an identical criteria it returns the collection . Otherwise if this CustomerGroup is new it will return an empty collection ; or if this CustomerGroup has previously been saved it will retrieve related CustomerCustomerGroups from storage .
|
12,969
|
public function initCustomerGroupI18ns ( $ overrideExisting = true ) { if ( null !== $ this -> collCustomerGroupI18ns && ! $ overrideExisting ) { return ; } $ this -> collCustomerGroupI18ns = new ObjectCollection ( ) ; $ this -> collCustomerGroupI18ns -> setModel ( '\CustomerGroup\Model\CustomerGroupI18n' ) ; }
|
Initializes the collCustomerGroupI18ns collection .
|
12,970
|
public function getCustomerGroupI18ns ( $ criteria = null , ConnectionInterface $ con = null ) { $ partial = $ this -> collCustomerGroupI18nsPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collCustomerGroupI18ns || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collCustomerGroupI18ns ) { $ this -> initCustomerGroupI18ns ( ) ; } else { $ collCustomerGroupI18ns = ChildCustomerGroupI18nQuery :: create ( null , $ criteria ) -> filterByCustomerGroup ( $ this ) -> find ( $ con ) ; if ( null !== $ criteria ) { if ( false !== $ this -> collCustomerGroupI18nsPartial && count ( $ collCustomerGroupI18ns ) ) { $ this -> initCustomerGroupI18ns ( false ) ; foreach ( $ collCustomerGroupI18ns as $ obj ) { if ( false == $ this -> collCustomerGroupI18ns -> contains ( $ obj ) ) { $ this -> collCustomerGroupI18ns -> append ( $ obj ) ; } } $ this -> collCustomerGroupI18nsPartial = true ; } reset ( $ collCustomerGroupI18ns ) ; return $ collCustomerGroupI18ns ; } if ( $ partial && $ this -> collCustomerGroupI18ns ) { foreach ( $ this -> collCustomerGroupI18ns as $ obj ) { if ( $ obj -> isNew ( ) ) { $ collCustomerGroupI18ns [ ] = $ obj ; } } } $ this -> collCustomerGroupI18ns = $ collCustomerGroupI18ns ; $ this -> collCustomerGroupI18nsPartial = false ; } } return $ this -> collCustomerGroupI18ns ; }
|
Gets an array of ChildCustomerGroupI18n objects which contain a foreign key that references this object .
|
12,971
|
public function countCustomerGroupI18ns ( Criteria $ criteria = null , $ distinct = false , ConnectionInterface $ con = null ) { $ partial = $ this -> collCustomerGroupI18nsPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collCustomerGroupI18ns || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collCustomerGroupI18ns ) { return 0 ; } if ( $ partial && ! $ criteria ) { return count ( $ this -> getCustomerGroupI18ns ( ) ) ; } $ query = ChildCustomerGroupI18nQuery :: create ( null , $ criteria ) ; if ( $ distinct ) { $ query -> distinct ( ) ; } return $ query -> filterByCustomerGroup ( $ this ) -> count ( $ con ) ; } return count ( $ this -> collCustomerGroupI18ns ) ; }
|
Returns the number of related CustomerGroupI18n objects .
|
12,972
|
public function addCustomerGroupI18n ( ChildCustomerGroupI18n $ l ) { if ( $ l && $ locale = $ l -> getLocale ( ) ) { $ this -> setLocale ( $ locale ) ; $ this -> currentTranslations [ $ locale ] = $ l ; } if ( $ this -> collCustomerGroupI18ns === null ) { $ this -> initCustomerGroupI18ns ( ) ; $ this -> collCustomerGroupI18nsPartial = true ; } if ( ! in_array ( $ l , $ this -> collCustomerGroupI18ns -> getArrayCopy ( ) , true ) ) { $ this -> doAddCustomerGroupI18n ( $ l ) ; } return $ this ; }
|
Method called to associate a ChildCustomerGroupI18n object to this object through the ChildCustomerGroupI18n foreign key attribute .
|
12,973
|
public function getCustomers ( $ criteria = null , ConnectionInterface $ con = null ) { if ( null === $ this -> collCustomers || null !== $ criteria ) { if ( $ this -> isNew ( ) && null === $ this -> collCustomers ) { $ this -> initCustomers ( ) ; } else { $ collCustomers = CustomerQuery :: create ( null , $ criteria ) -> filterByCustomerGroup ( $ this ) -> find ( $ con ) ; if ( null !== $ criteria ) { return $ collCustomers ; } $ this -> collCustomers = $ collCustomers ; } } return $ this -> collCustomers ; }
|
Gets a collection of ChildCustomer objects related by a many - to - many relationship to the current object by way of the customer_customer_group cross - reference table .
|
12,974
|
public function countCustomers ( $ criteria = null , $ distinct = false , ConnectionInterface $ con = null ) { if ( null === $ this -> collCustomers || null !== $ criteria ) { if ( $ this -> isNew ( ) && null === $ this -> collCustomers ) { return 0 ; } else { $ query = CustomerQuery :: create ( null , $ criteria ) ; if ( $ distinct ) { $ query -> distinct ( ) ; } return $ query -> filterByCustomerGroup ( $ this ) -> count ( $ con ) ; } } else { return count ( $ this -> collCustomers ) ; } }
|
Gets the number of ChildCustomer objects related by a many - to - many relationship to the current object by way of the customer_customer_group cross - reference table .
|
12,975
|
public function addCustomer ( ChildCustomer $ customer ) { if ( $ this -> collCustomers === null ) { $ this -> initCustomers ( ) ; } if ( ! $ this -> collCustomers -> contains ( $ customer ) ) { $ this -> doAddCustomer ( $ customer ) ; $ this -> collCustomers [ ] = $ customer ; } return $ this ; }
|
Associate a ChildCustomer object to this object through the customer_customer_group cross reference table .
|
12,976
|
public function isLast ( ConnectionInterface $ con = null ) { return $ this -> getPosition ( ) == ChildCustomerGroupQuery :: create ( ) -> getMaxRankArray ( $ con ) ; }
|
Check if the object is last in the list i . e . if its rank is the highest rank
|
12,977
|
public function getNext ( ConnectionInterface $ con = null ) { $ query = ChildCustomerGroupQuery :: create ( ) ; $ query -> filterByRank ( $ this -> getPosition ( ) + 1 ) ; return $ query -> findOne ( $ con ) ; }
|
Get the next item in the list i . e . the one for which rank is immediately higher
|
12,978
|
public function insertAtRank ( $ rank , ConnectionInterface $ con = null ) { $ maxRank = ChildCustomerGroupQuery :: create ( ) -> getMaxRankArray ( $ con ) ; if ( $ rank < 1 || $ rank > $ maxRank + 1 ) { throw new PropelException ( 'Invalid rank ' . $ rank ) ; } $ this -> setPosition ( $ rank ) ; if ( $ rank != $ maxRank + 1 ) { $ this -> sortableQueries [ ] = array ( 'callable' => array ( '\CustomerGroup\Model\CustomerGroupQuery' , 'sortableShiftRank' ) , 'arguments' => array ( 1 , $ rank , null , ) ) ; } return $ this ; }
|
Insert at specified rank The modifications are not persisted until the object is saved .
|
12,979
|
public function insertAtBottom ( ConnectionInterface $ con = null ) { $ this -> setPosition ( ChildCustomerGroupQuery :: create ( ) -> getMaxRankArray ( $ con ) + 1 ) ; return $ this ; }
|
Insert in the last rank The modifications are not persisted until the object is saved .
|
12,980
|
public function moveToRank ( $ newRank , ConnectionInterface $ con = null ) { if ( $ this -> isNew ( ) ) { throw new PropelException ( 'New objects cannot be moved. Please use insertAtRank() instead' ) ; } if ( null === $ con ) { $ con = Propel :: getServiceContainer ( ) -> getWriteConnection ( CustomerGroupTableMap :: DATABASE_NAME ) ; } if ( $ newRank < 1 || $ newRank > ChildCustomerGroupQuery :: create ( ) -> getMaxRankArray ( $ con ) ) { throw new PropelException ( 'Invalid rank ' . $ newRank ) ; } $ oldRank = $ this -> getPosition ( ) ; if ( $ oldRank == $ newRank ) { return $ this ; } $ con -> beginTransaction ( ) ; try { $ delta = ( $ oldRank < $ newRank ) ? - 1 : 1 ; ChildCustomerGroupQuery :: sortableShiftRank ( $ delta , min ( $ oldRank , $ newRank ) , max ( $ oldRank , $ newRank ) , $ con ) ; $ this -> setPosition ( $ newRank ) ; $ this -> save ( $ con ) ; $ con -> commit ( ) ; return $ this ; } catch ( Exception $ e ) { $ con -> rollback ( ) ; throw $ e ; } }
|
Move the object to a new rank and shifts the rank Of the objects inbetween the old and new rank accordingly
|
12,981
|
public function swapWith ( $ object , ConnectionInterface $ con = null ) { if ( null === $ con ) { $ con = Propel :: getServiceContainer ( ) -> getWriteConnection ( CustomerGroupTableMap :: DATABASE_NAME ) ; } $ con -> beginTransaction ( ) ; try { $ oldRank = $ this -> getPosition ( ) ; $ newRank = $ object -> getPosition ( ) ; $ this -> setPosition ( $ newRank ) ; $ object -> setPosition ( $ oldRank ) ; $ this -> save ( $ con ) ; $ object -> save ( $ con ) ; $ con -> commit ( ) ; return $ this ; } catch ( Exception $ e ) { $ con -> rollback ( ) ; throw $ e ; } }
|
Exchange the rank of the object with the one passed as argument and saves both objects
|
12,982
|
public function moveUp ( ConnectionInterface $ con = null ) { if ( $ this -> isFirst ( ) ) { return $ this ; } if ( null === $ con ) { $ con = Propel :: getServiceContainer ( ) -> getWriteConnection ( CustomerGroupTableMap :: DATABASE_NAME ) ; } $ con -> beginTransaction ( ) ; try { $ prev = $ this -> getPrevious ( $ con ) ; $ this -> swapWith ( $ prev , $ con ) ; $ con -> commit ( ) ; return $ this ; } catch ( Exception $ e ) { $ con -> rollback ( ) ; throw $ e ; } }
|
Move the object higher in the list i . e . exchanges its rank with the one of the previous object
|
12,983
|
public function moveDown ( ConnectionInterface $ con = null ) { if ( $ this -> isLast ( $ con ) ) { return $ this ; } if ( null === $ con ) { $ con = Propel :: getServiceContainer ( ) -> getWriteConnection ( CustomerGroupTableMap :: DATABASE_NAME ) ; } $ con -> beginTransaction ( ) ; try { $ next = $ this -> getNext ( $ con ) ; $ this -> swapWith ( $ next , $ con ) ; $ con -> commit ( ) ; return $ this ; } catch ( Exception $ e ) { $ con -> rollback ( ) ; throw $ e ; } }
|
Move the object higher in the list i . e . exchanges its rank with the one of the next object
|
12,984
|
public function moveToTop ( ConnectionInterface $ con = null ) { if ( $ this -> isFirst ( ) ) { return $ this ; } return $ this -> moveToRank ( 1 , $ con ) ; }
|
Move the object to the top of the list
|
12,985
|
public function moveToBottom ( ConnectionInterface $ con = null ) { if ( $ this -> isLast ( $ con ) ) { return false ; } if ( null === $ con ) { $ con = Propel :: getServiceContainer ( ) -> getWriteConnection ( CustomerGroupTableMap :: DATABASE_NAME ) ; } $ con -> beginTransaction ( ) ; try { $ bottom = ChildCustomerGroupQuery :: create ( ) -> getMaxRankArray ( $ con ) ; $ res = $ this -> moveToRank ( $ bottom , $ con ) ; $ con -> commit ( ) ; return $ res ; } catch ( Exception $ e ) { $ con -> rollback ( ) ; throw $ e ; } }
|
Move the object to the bottom of the list
|
12,986
|
public function removeFromList ( ) { $ this -> sortableQueries [ ] = array ( 'callable' => array ( '\CustomerGroup\Model\CustomerGroupQuery' , 'sortableShiftRank' ) , 'arguments' => array ( - 1 , $ this -> getPosition ( ) + 1 , null ) ) ; $ this -> setPosition ( null ) ; return $ this ; }
|
Removes the current object from the list . The modifications are not persisted until the object is saved .
|
12,987
|
protected function addArgument ( $ argument , $ descriptor ) { $ params = $ descriptor -> getTags ( ) -> get ( 'param' , array ( ) ) ; if ( ! $ this -> argumentAssembler -> getBuilder ( ) ) { $ this -> argumentAssembler -> setBuilder ( $ this -> builder ) ; } $ argumentDescriptor = $ this -> argumentAssembler -> create ( $ argument , $ params ) ; $ descriptor -> addArgument ( $ argumentDescriptor -> getName ( ) , $ argumentDescriptor ) ; }
|
Adds a single reflected Argument to the Method Descriptor .
|
12,988
|
public function initiate ( $ template = null , $ data = null , $ templateRootFolder = ERDIKO_APP ) { $ template = ( $ template === null ) ? $ this -> getDefaultTemplate ( ) : $ template ; $ this -> setTemplate ( $ template ) ; $ this -> setData ( $ data ) ; $ this -> setTemplateRootFolder ( $ templateRootFolder ) ; }
|
Constructor like initiation
|
12,989
|
protected function addTemplateAssets ( $ template ) { foreach ( $ template -> getAssets ( ) as $ filename => $ file_info ) { $ this -> assets -> set ( $ filename , $ file_info -> getRelativePathname ( ) ) ; } }
|
Adds the assets of the template to the Assets manager .
|
12,990
|
public function getInlcudeResources ( $ resource ) { switch ( $ resource ) { case 'administrative_areas' : return $ this -> administrativeAreas ( ) -> getQuery ( ) ; case 'cities' : return $ this -> cities ( ) -> getQuery ( ) -> select ( "ctrystore_cities.*" ) ; } return false ; }
|
Check if resource is related with the model . Then return resource query .
|
12,991
|
function email ( $ str , $ mx = TRUE ) { $ hosts = array ( ) ; return is_string ( filter_var ( $ str , FILTER_VALIDATE_EMAIL ) ) && ( ! $ mx || getmxrr ( substr ( $ str , strrpos ( $ str , '@' ) + 1 ) , $ hosts ) ) ; }
|
Return TRUE if string is a valid e - mail address ; Check DNS MX records if specified
|
12,992
|
public static function categoryList ( ) { $ data = self :: find ( ) -> orderBy ( 'category' ) -> groupBy ( [ 'category' ] ) -> select ( [ 'category' ] ) -> column ( ) ; return array_combine ( $ data , $ data ) ; }
|
Gets all used categories list .
|
12,993
|
protected function filterList ( array $ nodes = array ( ) , array $ rules = array ( ) ) { if ( ! empty ( $ rules ) ) { foreach ( $ nodes as $ node ) { if ( ! $ node instanceof Node ) continue ; $ props = $ node -> getInfo ( FALSE ) ; $ props = array_intersect_key ( $ props , $ rules ) ; foreach ( $ props as $ key => $ val ) { if ( $ val instanceof Str ) { $ match = $ val -> contains ( $ rules [ $ key ] , TRUE ) ; } else { $ match = $ val == $ rules [ $ key ] ; } if ( $ match === FALSE ) { unset ( $ nodes [ $ node -> getId ( ) ] ) ; } } } } return $ nodes ; }
|
Filters given node list array using specified filter rules .
|
12,994
|
public static function addCustomerGroupsFilter ( ModelCriteria $ query , array $ customerGroups ) { if ( ! is_array ( $ customerGroups ) || empty ( $ customerGroups ) ) { return $ query ; } $ query -> addJoin ( CustomerTableMap :: ID , CustomerCustomerGroupTableMap :: CUSTOMER_ID , Criteria :: LEFT_JOIN ) -> addJoin ( CustomerCustomerGroupTableMap :: CUSTOMER_GROUP_ID , CustomerGroupTableMap :: ID , Criteria :: LEFT_JOIN ) ; $ groupConditionsNames = [ ] ; foreach ( $ customerGroups as $ customerGroup ) { $ conditionName = 'condition_customer_group_' . $ customerGroup ; $ query -> condition ( $ conditionName , CustomerGroupTableMap :: CODE . Criteria :: EQUAL . "?" , $ customerGroup , \ PDO :: PARAM_STR ) ; $ groupConditionsNames [ ] = $ conditionName ; } if ( ! empty ( $ groupConditionsNames ) ) { $ query -> where ( $ groupConditionsNames , Criteria :: LOGICAL_OR ) ; } return $ query ; }
|
Filter the query by customer groups .
|
12,995
|
public function createLoader ( array $ autoloads ) { $ loader = new ClassLoader ( ) ; if ( isset ( $ autoloads [ 'psr-0' ] ) ) { foreach ( $ autoloads [ 'psr-0' ] as $ namespace => $ path ) { $ loader -> add ( $ namespace , $ path ) ; } } if ( isset ( $ autoloads [ 'psr-4' ] ) ) { foreach ( $ autoloads [ 'psr-4' ] as $ namespace => $ path ) { $ loader -> addPsr4 ( $ namespace , $ path ) ; } } return $ loader ; }
|
Registers an autoloader based on an autoload map returned by parseAutoloads
|
12,996
|
protected function getPath ( $ name , $ path ) { $ timestamp = Carbon :: now ( ) ; if ( in_array ( $ timestamp , $ this -> usedTimestamps ) ) { $ timestamp -> addSecond ( ) ; } $ this -> usedTimestamps [ ] = $ timestamp ; return $ path . '/' . $ timestamp -> format ( 'Y_m_d_His' ) . '_' . $ this -> getName ( $ name ) . '.php' ; }
|
Constructs path to migration file in Laravel style .
|
12,997
|
public function validate ( $ descriptor ) { $ violations = $ this -> validator -> validate ( $ descriptor ) ; $ errors = new Collection ( ) ; foreach ( $ violations as $ violation ) { $ errors -> add ( new Error ( $ this -> mapCodeToSeverity ( $ violation -> getCode ( ) ) , $ violation -> getMessageTemplate ( ) , $ descriptor -> getLine ( ) , $ violation -> getMessageParameters ( ) + array ( $ descriptor -> getFullyQualifiedStructuralElementName ( ) ) ) ) ; } return $ errors ; }
|
Validates the contents of the Descriptor and outputs warnings and error if something is amiss .
|
12,998
|
protected function mapCodeToSeverity ( $ code ) { if ( is_int ( $ code ) && $ this -> translator -> translate ( 'VAL:ERRLVL-' . $ code ) ) { $ severity = $ this -> translator -> translate ( 'VAL:ERRLVL-' . $ code ) ; } else { $ severity = LogLevel :: ERROR ; } return $ severity ; }
|
Map error code to severity .
|
12,999
|
public function _render ( $ textOnly ) { $ str = "" ; if ( $ textOnly ) $ str .= "\nModel Analysis\n==============\n" ; else $ str .= "<h2>Model Analysis</h2>" ; $ str .= $ this -> analyzeModel ( $ this -> configuration -> getModel ( ) , $ textOnly ) ; if ( $ textOnly ) $ str .= "\nConfiguration Analysis\n======================\n" ; else $ str .= "</td><td valign='top'><h2>Configuration Analysis</h2>" ; $ str .= $ this -> analyzeConfiguration ( $ this -> configuration , $ textOnly ) ; return $ str ; }
|
Returns the model and configuration analysis .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.