idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
6,000
public static function all ( $ params = array ( ) , $ opts = null ) { $ list = parent :: all ( $ params , $ opts ) ; $ chList = new ChargeCollection ( ) ; $ chList -> install ( $ list -> values , $ list -> opts ) ; return $ chList ; }
Get Charge list .
6,001
public function refund ( $ params , $ opts = null ) { $ url = self :: classUrl ( ) . '/' . $ this -> instanceId ( ) . "/refund" ; list ( $ resp , $ usedOpts ) = self :: request ( self :: METHOD_POST , $ url , $ params , $ opts ) ; $ this -> install ( $ resp , $ usedOpts ) ; return $ this ; }
Refund order .
6,002
public function refresh ( ) { $ url = self :: classUrl ( ) . "?id=" . $ this -> instanceId ( ) ; list ( $ resp , $ usedOpts ) = self :: request ( self :: METHOD_GET , $ url ) ; $ body = isset ( $ resp [ 'data' ] [ 0 ] ) ? $ resp [ 'data' ] [ 0 ] : null ; $ this -> install ( $ body , $ usedOpts ) ; return $ this ; }
Update Charge object information to the latest .
6,003
public function set ( $ name , $ value = null ) : self { if ( ! is_array ( $ name ) ) { $ name = [ $ name => $ value ] ; } foreach ( $ name as $ property => $ value ) { $ this -> _data [ $ property ] = $ value ; } return $ this ; }
Property setter .
6,004
public function add ( string $ name , ? string $ key , $ value ) : self { if ( ! isset ( $ this -> _data [ $ name ] ) ) { $ this -> _data [ $ name ] = [ ] ; } if ( $ key === null ) { $ key = count ( $ this -> _data [ $ name ] ) ; } $ this -> _data [ $ name ] [ $ key ] = $ value ; return $ this ; }
Property setter adding to associative arrays .
6,005
public function get ( string $ name ) { if ( ! isset ( $ this -> _data [ $ name ] ) ) { return null ; } return $ this -> _data [ $ name ] ; }
Property getter .
6,006
protected function _encode ( ) : string { $ data = json_encode ( $ this , JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ) ; if ( $ data === false ) { throw new \ Exception ( 'Invalid data' ) ; } $ data = preg_replace_callback ( '/"::FUNCTION::(.*?)::FUNCTION::"/' , function ( $ matches ) { return stripcslashes ( $ ma...
Handle json_encode .
6,007
public function read ( $ fallbackToDefault = false ) { $ configFile = Config :: FILENAME ; if ( ! is_file ( $ configFile ) ) { if ( $ fallbackToDefault === false ) { return null ; } $ configFile = __DIR__ . '/magedeploy2.default.php' ; } $ data = include $ configFile ; $ config = new Config ( $ data ) ; return $ config...
Read Config from file and initialize Config object
6,008
private static function interpretResponse ( $ rstatus , $ rheader , $ rbody ) { if ( $ rstatus < 200 || $ rstatus >= 300 ) { self :: handleError ( $ rstatus , $ rheader , $ rbody ) ; } elseif ( empty ( $ rbody ) ) { throw new Error \ Api ( 'Invalid response from API' , $ rstatus , $ rheader , $ rbody ) ; } $ resp = jso...
Check response information . If it is valid one JSON array will be returned .
6,009
protected static function all ( $ params , $ opts ) { $ url = self :: classUrl ( ) ; list ( $ resp , $ usedOpts ) = self :: request ( self :: METHOD_GET , $ url , $ params , $ opts ) ; $ resp = Util \ Util :: arrayToObject ( $ resp , $ usedOpts ) ; if ( ! is_a ( $ resp , 'RpayLite\\Collection' ) ) { $ class = get_class...
Call API that will return the list which has multiple objects .
6,010
public static function parseBlockJs ( $ js ) { $ jsBlockPattern = '|^<script[^>]*>(?P<block_content>.+?)</script>$|is' ; if ( preg_match ( $ jsBlockPattern , trim ( $ js ) , $ matches ) ) { $ js = trim ( $ matches [ 'block_content' ] ) ; } return $ js ; }
Only get script inner of script tag .
6,011
protected function wrapAll ( array $ result ) : array { $ modelName = $ this -> getModelName ( ) ; foreach ( $ result as & $ entity ) { $ entity = $ this -> createModel ( $ modelName , $ entity ) ; } return $ result ; }
Wraps all DAO result entities in model instances
6,012
public function searchOne ( array $ cond = array ( ) ) { $ options = array ( 'count' => 1 , 'offset' => 0 ) ; $ result = $ this -> search ( $ cond , $ options ) ; if ( $ result [ 'total' ] != 1 ) { throw new NotFoundException ( $ result [ 'total' ] . ' matching items found' ) ; } return $ result -> getFirstResult ( ) ;...
Search a single record ; throws an exception if 0 or more than one record are found
6,013
public function searchIds ( array $ cond , array $ options = array ( ) ) : SearchResult { $ params = $ options + array ( 'cond' => $ cond ) ; $ params [ 'ids_only' ] = true ; $ result = $ this -> getEntityDao ( ) -> search ( $ params ) ; if ( ! $ result instanceof SearchResult ) { throw new FindException ( 'Data Access...
Returns an array of matching primary keys for the given search condition
6,014
public function batchEdit ( array $ ids , array $ properties ) { $ this -> getEntityDao ( ) -> beginTransaction ( ) ; try { foreach ( $ ids as $ id ) { $ dao = $ this -> createDao ( ) ; $ dao -> find ( $ id ) ; foreach ( $ properties as $ key => $ value ) { $ dao -> $ key = $ value ; } $ dao -> update ( ) ; } $ this ->...
Update the data of multiple DAO instances
6,015
public function delete ( ) { if ( ! $ this -> hasId ( ) ) { throw new DeleteException ( 'ID not set - did you call find($id) before delete()?' ) ; } if ( ! $ this -> isDeletable ( ) ) { throw new DeleteException ( 'Permission denied: Entity can not be deleted' ) ; } $ this -> transactional ( function ( ) { $ this -> fo...
Permanently deletes the entity instance
6,016
public function update ( array $ values ) { if ( ! $ this -> hasId ( ) ) { throw new UpdateException ( 'ID not set - did you call find($id) before update($values)?' ) ; } if ( ! $ this -> isUpdatable ( ) ) { throw new UpdateException ( 'Permission denied: Entity can not be updated' ) ; } $ this -> transactional ( funct...
Updates the entity using the given values
6,017
public function forceUpdate ( array $ values ) { $ dao = $ this -> getEntityDao ( ) ; $ dao -> setValues ( $ values ) ; $ dao -> update ( ) ; return $ this ; }
Updates the entity without transaction & permission checks
6,018
public function save ( array $ values ) { if ( ! $ this -> isSavable ( ) ) { throw new CreateException ( 'Permission denied: Entity can not be saved' ) ; } $ this -> transactional ( function ( ) use ( $ values ) { $ this -> forceSave ( $ values ) ; } ) ; return $ this ; }
Save a new entity using the given values
6,019
public function forceSave ( array $ values ) { $ dao = $ this -> getEntityDao ( ) ; $ dao -> setValues ( $ values ) ; $ dao -> save ( ) ; $ dao -> reload ( ) ; return $ this ; }
Creates the entity without transaction & permission checks
6,020
public function getHost ( $ locale ) { if ( ! isset ( $ this -> localesConfig [ $ locale ] [ 'host' ] ) ) { return null ; } return $ this -> localesConfig [ $ locale ] [ 'host' ] ; }
Returns host configured for a locale or null if not found .
6,021
public function prefixPath ( $ locale , $ path ) { if ( isset ( $ this -> localesConfig [ $ locale ] [ 'prefix' ] ) ) { return $ this -> localesConfig [ $ locale ] [ 'prefix' ] . $ path ; } return $ path ; }
Prefixes the path for a given locale if a prefix is configured .
6,022
public function getOption ( $ locale , $ name , $ default = null ) { return isset ( $ this -> localesConfig [ $ locale ] [ $ name ] ) ? $ this -> localesConfig [ $ locale ] [ $ name ] : $ default ; }
Returns value of an option .
6,023
public function matches ( $ path ) { if ( preg_match ( $ this -> expr , $ path , $ this -> matches ) && in_array ( $ _SERVER [ 'REQUEST_METHOD' ] , $ this -> methods ) ) { return true ; } return false ; }
See if route matches with path
6,024
public function objectTag ( $ oldFields = [ ] ) { $ primaryKey = null ; if ( count ( $ this -> primaryKey ( ) ) === 1 ) { $ key = $ this -> primaryKey ( ) [ 0 ] ; $ primaryKey = isset ( $ oldFields [ $ key ] ) ? $ oldFields [ $ key ] : $ this -> $ key ; } else { $ primaryKey = [ ] ; foreach ( $ this -> primaryKey ( ) a...
Returns object tag name including it s id
6,025
public function objectCompositeTag ( $ oldFields = [ ] ) { $ cacheFields = $ this -> cacheCompositeTagFields ( ) ; if ( empty ( $ cacheFields ) ) { return [ ] ; } $ cacheFields = ( is_array ( $ cacheFields ) && ! empty ( $ cacheFields ) && is_array ( $ cacheFields [ 0 ] ) ) ? $ cacheFields : [ $ cacheFields ] ; $ tags ...
Returns composite tags name including fields
6,026
public function invalidateTags ( $ event = null ) { $ oldFields = $ event !== null && $ event -> name === ActiveRecord :: EVENT_AFTER_UPDATE ? $ event -> changedAttributes : [ ] ; \ yii \ caching \ TagDependency :: invalidate ( $ this -> getTagDependencyCacheComponent ( ) , [ static :: commonTag ( ) , $ this -> objectT...
Invalidate model tags .
6,027
public static function retrieve ( $ charge , $ id , $ opts = null ) { $ list = self :: all ( array ( 'id' => $ id ) , $ opts ) ; $ nt = new Notification ( ) ; $ nt -> install ( $ list -> data [ 0 ] -> values , $ list -> opts ) ; return $ nt ; }
Get Notification object which has specific ID and Charge ID .
6,028
public static function all ( $ params , $ opts = null ) { $ list = parent :: all ( $ params , $ opts ) ; $ ntList = new NotificationCollection ( ) ; $ ntList -> install ( $ list -> values , $ list -> opts ) ; return $ ntList ; }
Get Notification list
6,029
public function refresh ( ) { list ( $ resp , $ usedOpts ) = self :: request ( self :: METHOD_GET , self :: instanceUrl ( ) ) ; $ body = isset ( $ resp [ 'data' ] [ 0 ] ) ? $ resp [ 'data' ] [ 0 ] : null ; $ this -> install ( $ body , $ usedOpts ) ; return $ this ; }
Update Notification object information to the latest .
6,030
protected function fetchSingleValue ( $ statement , array $ params = array ( ) , array $ types = array ( ) ) { return $ this -> getDb ( ) -> fetchColumn ( $ statement , $ params , 0 , $ types ) ; }
Returns value of the first column of the first row
6,031
protected function fetchCol ( $ statement , array $ params = array ( ) , array $ types = array ( ) ) : array { $ result = array ( ) ; $ rows = $ this -> getDb ( ) -> fetchAll ( $ statement , $ params , $ types ) ; foreach ( $ rows as $ row ) { $ result [ ] = current ( $ row ) ; } return $ result ; }
Returns values of the first column as array
6,032
protected function describeTable ( string $ tableName ) : array { if ( isset ( $ this -> _tableDescription [ $ tableName ] ) ) { return $ this -> _tableDescription [ $ tableName ] ; } $ result = array ( ) ; $ statement = 'DESCRIBE ' . $ this -> getDb ( ) -> quoteIdentifier ( $ tableName ) ; $ cols = $ this -> fetchAll ...
Returns column names and types as array
6,033
static public function get_coin_network ( $ symbol , $ network , $ silentfail = false ) { $ data = self :: get_coin ( $ symbol , $ silentfail ) ; $ info = @ $ data [ $ network ] ; if ( ! $ info && ! $ silentfail ) { throw new \ Exception ( "Network not found: $symbol/$network" ) ; } return $ info ; }
returns information about coin + network
6,034
static public function get_all_coins ( ) { static $ data = null ; if ( $ data ) { return $ data ; } $ buf = self :: get_raw_json ( ) ; $ data = @ json_decode ( $ buf , true ) ; if ( ! $ data ) { throw new \ Exception ( "Unable to parse json: " . json_last_error_msg ( ) ) ; } return $ data ; }
returns parsed json data for all coins
6,035
protected function sortRoutes ( array $ routes ) { if ( ! $ this -> sortRoutes ) { return $ routes ; } $ hosts = array ( ) ; foreach ( $ routes as $ name => $ route ) { $ branding = $ route -> getDefault ( '_branding' ) ; $ locale = $ route -> getDefault ( '_locale' ) ; $ hosts [ $ branding . '__' . $ locale ] [ $ name...
Sort routes by domain .
6,036
private function setMatchContext ( array $ match ) { if ( isset ( $ match [ '_branding' ] ) ) { $ this -> context -> setParameter ( '_branding' , $ match [ '_branding' ] ) ; $ this -> siteContext -> setCurrentBranding ( $ this -> siteContext -> getBranding ( $ match [ '_branding' ] ) ) ; } if ( isset ( $ match [ '_loca...
Changes router context and site context according to matched route .
6,037
public function getAvatarUrl ( $ size = 96 ) { $ avatarUrls = $ this -> getValueByKey ( $ this -> response , 'avatar_urls' ) ; return in_array ( $ size , array ( '24' , '48' , '96' ) ) ? $ avatarUrls [ $ size ] : null ; }
Get resource owner avatar url
6,038
protected function getClassName ( $ name ) { if ( empty ( $ name ) ) { throw new $ this -> _factoryExceptionClassName ( '$name must not be empty' ) ; } $ result = $ this -> getFactoryNamespace ( ) . '\\' . $ name . $ this -> getFactoryPostfix ( ) ; if ( ! class_exists ( $ result ) ) { throw new $ this -> _factoryExcept...
Returns complete class name
6,039
public function getCurrentBranding ( ) { if ( null === $ this -> currentBranding ) { return $ this -> getBranding ( $ this -> defaultBrandingName ) ; } return $ this -> currentBranding ; }
Returns current branding .
6,040
public function getBranding ( $ name ) { foreach ( $ this -> brandings as $ branding ) { if ( $ branding -> getName ( ) === $ name ) { return $ branding ; } } $ names = array_map ( function ( $ branding ) { return $ branding -> getName ( ) ; } , $ this -> brandings ) ; throw new \ InvalidArgumentException ( sprintf ( '...
Returns a given branding .
6,041
public function getBrandingsWithLocale ( $ locale ) { $ result = array ( ) ; foreach ( $ this -> brandings as $ branding ) { if ( $ branding -> hasLocale ( $ locale ) ) { $ result [ ] = $ branding ; } } return $ result ; }
Returns brandings with a given locale .
6,042
public static function isRpayLiteClassType ( $ class , $ type ) { if ( array_key_exists ( $ class , self :: $ types ) && in_array ( $ type , self :: $ types [ $ class ] ) ) { return true ; } return false ; }
Detect whether the given class and type are supported by this SDK .
6,043
public static function arrayToObject ( $ resp , $ opts = null ) { if ( self :: isIndexedArray ( $ resp ) ) { $ objArray = array ( ) ; foreach ( $ resp as $ val ) { array_push ( $ objArray , self :: arrayToObject ( $ val , $ opts ) ) ; } return $ objArray ; } elseif ( is_array ( $ resp ) ) { if ( isset ( $ resp [ 'objec...
Convert JSON array created by json_encode to any class instance which is corresponding to the included object JSON property . It returns the given value as is if the object does not exist .
6,044
public static function objectToArray ( $ values ) { $ results = array ( ) ; foreach ( $ values as $ key => $ val ) { if ( $ val instanceof RpayLiteObject ) { $ results [ $ key ] = $ val -> __toArray ( true ) ; } elseif ( is_array ( $ val ) ) { $ results [ $ key ] = self :: objectToArray ( $ val ) ; } else { $ results [...
Convert RpayLiteObject to an array .
6,045
public static function objectize ( $ name , $ elems ) { $ objectized = array ( ) ; foreach ( $ elems as $ elem ) { $ elem [ 'object' ] = $ name ; array_push ( $ objectized , $ elem ) ; } return $ objectized ; }
Inject object property in to the given JSON object . This feature is used for handling Item as the independent class . Items is better to be class but it does not have object property .
6,046
public static function isIndexedArray ( $ arr ) { if ( ! is_array ( $ arr ) ) { return false ; } if ( array_values ( $ arr ) === $ arr ) { return true ; } return false ; }
Check whether the given array is associative or indexed .
6,047
private static function parseClassType ( $ type ) { $ ct = explode ( '.' , $ type ) ; if ( count ( $ ct ) != 2 ) { return false ; } $ _class = $ ct [ 0 ] ; $ _type = $ ct [ 1 ] ; if ( self :: isRpayLiteClassType ( $ _class , $ _type ) ) { return $ _type ; } else { return false ; } }
Parse data for classType method .
6,048
function get ( $ url ) { $ snoopy = $ this -> getSnoopyInstance ( ) ; $ snoopy -> fetch ( $ url ) ; return $ this -> processSnoopyResponse ( $ snoopy ) ; }
GET data readre
6,049
private function processSnoopyResponse ( \ Snoopy & $ snoopy ) { if ( $ snoopy -> status != 200 ) { throw new CallFailed ( $ snoopy -> status , $ snoopy -> results ) ; } else { return $ snoopy -> results ; } }
Process Snoopy response
6,050
private function getSnoopyInstance ( ) { require_once $ this -> snoopy_class_path ; $ snoopy = new \ Snoopy ( ) ; $ snoopy -> agent = Client :: getUserAgent ( ) ; return $ snoopy ; }
Return Snoopy instance
6,051
protected function addMultisiteRoute ( RouteCollection $ collection , $ annot , $ globals , \ ReflectionClass $ class , \ ReflectionMethod $ method ) { $ paths = $ this -> siteContext -> normalizePaths ( $ annot -> getPaths ( ) ) ; foreach ( $ paths as $ branding => $ locales ) { foreach ( $ locales as $ locale => $ pa...
Specific method to add a multisite route to the collection .
6,052
public function set ( $ path , $ value ) { if ( strpos ( $ path , '/' ) === false ) { $ this -> data [ $ path ] = $ value ; return $ this ; } $ pathKeys = explode ( '/' , $ path ) ; $ key = array_pop ( $ pathKeys ) ; $ data = & $ this -> data ; foreach ( $ pathKeys as $ pathKey ) { if ( is_array ( $ data ) && array_key...
Set a Config Value
6,053
private function & getHandle ( $ url ) { $ http = curl_init ( ) ; curl_setopt ( $ http , CURLOPT_USERAGENT , Client :: getUserAgent ( ) ) ; curl_setopt ( $ http , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ http , CURLOPT_URL , $ url ) ; return $ http ; }
Return curl resource
6,054
private function execute ( & $ http ) { $ result = curl_exec ( $ http ) ; if ( $ result === false ) { $ error_code = curl_errno ( $ http ) ; $ error_message = curl_error ( $ http ) ; curl_close ( $ http ) ; throw new CallFailed ( $ error_code , $ result , $ error_message ) ; } else { $ status = ( integer ) curl_getinfo...
Do the call
6,055
public function getAllResultsAsArray ( ) : array { $ result = array ( ) ; $ entities = $ this -> getAllResults ( ) ; foreach ( $ entities as $ entity ) { if ( is_object ( $ entity ) && method_exists ( $ entity , 'getValues' ) ) { $ result [ ] = $ entity -> getValues ( ) ; } else { $ result [ ] = ( array ) $ entity ; } ...
Returns all results as nested array .
6,056
public static function constructEvent ( $ jsonString , $ header , $ expectedSignature = null ) { self :: verifySignature ( $ header , $ expectedSignature ) ; return Event :: parseJson ( $ jsonString ) ; }
Create new Event object from given JSON string .
6,057
private static function verifySignature ( $ signature , $ expectedSignature = null ) { if ( ! isset ( $ expectedSignature ) && ! isset ( RpayLite :: $ webhookSignature ) ) { throw new Error \ SignatureVerification ( 'Webhook Signature is not defined.' ) ; } $ expected = $ expectedSignature ? $ expectedSignature : RpayL...
Validate signature .
6,058
private function addBrandingDefinition ( ContainerBuilder $ container , array $ options ) { $ brandings = array ( ) ; if ( isset ( $ options [ '_defaults' ] ) ) { $ globalOptions = $ options [ '_defaults' ] ; unset ( $ options [ '_defaults' ] ) ; } else { $ globalOptions = array ( ) ; } foreach ( $ options as $ name =>...
Adds configured brandings to the site context service .
6,059
public function deleteItem ( $ id ) { $ updatedItems = $ this -> values [ 'items' ] ; foreach ( $ updatedItems as $ index => $ item ) { if ( $ item [ 'id' ] == $ id ) { unset ( $ updatedItems [ $ index ] ) ; } } $ this -> values [ 'items' ] = array_values ( $ updatedItems ) ; }
Remove a item having specific ID .
6,060
public function toHtml ( $ sig = true ) { $ html = '<script' ; $ html = $ html . ' src="' . self :: BUTTON_SRC . '"' ; $ html = $ html . ' class="' . self :: BUTTON_CLASS . '"' ; if ( isset ( $ this -> values [ 'key' ] ) ) { $ html = $ html . ' data-key="' . $ this -> values [ 'key' ] . '"' ; } if ( isset ( $ this -> v...
Generate HTML of payment button from registered information .
6,061
private function signature ( ) { if ( isset ( $ this -> apiKey ) ) { $ apiKey = $ this -> apiKey ; } else { $ apiKey = \ RpayLite \ RpayLite :: $ apiKey ; } $ array_payload = array ( ) ; array_push ( $ array_payload , $ this [ 'key' ] ) ; foreach ( $ this [ 'items' ] as $ item ) { array_push ( $ array_payload , $ item ...
Generate data - sig from registered information .
6,062
public static function isLive ( ) { if ( preg_match ( "/^(live_private_|test_private_)/" , self :: $ apiKey ) ) { return true ; } elseif ( preg_match ( "/^sandbox_private_/" , self :: $ apiKey ) ) { return false ; } else { throw new Error \ InvalidApiKey ( 'Set correct secret key.' ) ; } }
Check whether target environment is live or sandbox . Detected by the prefix of the Secret key .
6,063
public function merge ( $ opts ) { $ primary_opts = self :: parse ( $ opts ) ; if ( $ primary_opts -> apiKey === null ) { $ primary_opts -> apiKey = $ this -> apiKey ; } $ primary_opts -> headers = array_merge ( $ this -> headers , $ primary_opts -> headers ) ; return $ primary_opts ; }
Unify given options with this instance has .
6,064
public static function parse ( $ opts ) { if ( $ opts instanceof self ) { return $ opts ; } if ( is_null ( $ opts ) ) { return new Options ( null , array ( ) ) ; } if ( is_array ( $ opts ) ) { $ key = null ; if ( array_key_exists ( 'api_key' , $ opts ) ) { $ key = $ opts [ 'api_key' ] ; unset ( $ opts [ 'api_key' ] ) ;...
Load options from array .
6,065
public function add ( $ expr , $ callback , $ methods = null ) { $ this -> all ( $ expr , $ callback , $ methods ) ; }
Alias for all
6,066
public function route ( ) { foreach ( $ this -> routes as $ route ) { if ( $ route -> matches ( $ this -> path ) ) { return $ route -> exec ( ) ; } } throw new RouteNotFoundException ( "No routes matching {$this->path}" ) ; }
Test all routes until any of them matches
6,067
public function url ( $ path = null ) { if ( $ path === null ) { $ path = $ this -> path ; } return $ this -> base_path . $ path ; }
Get the current url or the url to a path
6,068
public function redirect ( $ from_path , $ to_path , $ code = 302 ) { $ this -> all ( $ from_path , function ( ) use ( $ to_path , $ code ) { http_response_code ( $ code ) ; header ( "Location: {$to_path}" ) ; } ) ; }
Redirect from one url to another
6,069
protected function initEnvironment ( ) { $ path = getcwd ( ) ; if ( ! is_file ( "$path/.env" ) ) { return ; } $ dotenv = new \ Dotenv \ Dotenv ( $ path ) ; if ( $ this -> dotEnvOverload ) { $ dotenv -> overload ( ) ; } else { $ dotenv -> load ( ) ; } }
Initialize Environment variables by . env file
6,070
protected function taskMagentoCleanVarDirs ( ) { $ magentoDir = $ this -> config ( Config :: KEY_DEPLOY . '/' . Config :: KEY_APP_DIR ) ; $ varDirs = $ this -> config ( Config :: KEY_DEPLOY . '/' . Config :: KEY_CLEAN_DIRS ) ; $ dirs = [ ] ; foreach ( $ varDirs as $ dir ) { $ dirPath = $ dir ; if ( ! empty ( $ magentoD...
Build Task to clean all var dirs
6,071
protected function taskMysqlCreateDatabase ( $ dropDatabase = false ) { $ dbName = $ this -> config ( CONFIG :: KEY_BUILD . '/' . Config :: KEY_DB . '/db-name' ) ; $ sqlDropDb = "DROP DATABASE `{$dbName}`" ; $ sqlCreateDb = "CREATE DATABASE IF NOT EXISTS `{$dbName}`" ; $ collection = $ this -> collectionBuilder ( ) ; $...
Build Task to create database
6,072
protected function taskMagentoSetProductionMode ( ) { $ magentoDir = $ this -> config ( Config :: KEY_DEPLOY . '/' . Config :: KEY_APP_DIR ) ; $ task = $ this -> taskMagentoDeploySetModeTask ( ) ; $ task -> modeProduction ( ) ; $ task -> skipCompilation ( ) ; $ task -> dir ( $ magentoDir ) ; return $ task ; }
Build Task to set magento to production mode
6,073
protected function taskMagentoSetupDiCompile ( ) { $ magentoDir = $ this -> config ( Config :: KEY_DEPLOY . '/' . Config :: KEY_APP_DIR ) ; $ task = $ this -> taskMagentoSetupDiCompileTask ( ) ; $ task -> dir ( $ magentoDir ) ; return $ task ; }
Build Task to run magento setup di compile
6,074
protected function taskMagentoSetupStaticContentDeploy ( ) { $ themes = $ this -> config ( Config :: KEY_DEPLOY . '/' . Config :: KEY_THEMES ) ; $ magentoDir = $ this -> config ( Config :: KEY_DEPLOY . '/' . Config :: KEY_APP_DIR ) ; $ collection = $ this -> collectionBuilder ( ) ; foreach ( $ themes as $ theme ) { if ...
Build Task to run magento setup static content deploy
6,075
protected function taskArtifactCreatePackages ( ) { $ rootDir = getcwd ( ) ; $ tarBin = $ this -> config ( Config :: KEY_ENV . '/' . Config :: KEY_TAR_BIN ) ; $ gitDir = $ this -> config ( Config :: KEY_DEPLOY . '/' . Config :: KEY_GIT_DIR ) ; $ artifactsDir = $ this -> config ( Config :: KEY_DEPLOY . '/' . Config :: K...
Build Task for artifact creation
6,076
protected function taskDeployerDeploy ( $ stage , $ branch ) { $ deployerBin = $ this -> config ( Config :: KEY_ENV . '/' . Config :: KEY_DEPLOYER_BIN ) ; $ task = $ this -> taskDeployerDeployTask ( $ deployerBin ) ; if ( $ this -> isTag ( $ branch ) ) { $ task -> tag ( $ branch ) ; } else { $ task -> branch ( $ branch...
Build Task for deployer deploy
6,077
protected function taskMysqlCommand ( ) { $ mysqlBin = $ this -> config ( Config :: KEY_ENV . '/' . Config :: KEY_MYSQL_BIN ) ; $ dbHost = $ this -> config ( CONFIG :: KEY_BUILD . '/' . Config :: KEY_DB . '/db-host' ) ; $ dbUser = $ this -> config ( CONFIG :: KEY_BUILD . '/' . Config :: KEY_DB . '/db-user' ) ; $ dbPass...
Create a mysql Command
6,078
protected function createTask ( ) { $ task = \ call_user_func_array ( [ 'parent' , 'task' ] , \ func_get_args ( ) ) ; $ task -> setInput ( $ this -> input ( ) ) ; $ task -> setOutput ( $ this -> output ( ) ) ; return $ task ; }
Create a Task and transfer input and output instances
6,079
protected function get ( string $ uri , array $ query = [ ] ) { $ response = $ this -> client -> request ( 'GET' , $ uri , $ query ? [ 'query' => $ query ] : [ ] ) ; return json_decode ( ( string ) $ response -> getBody ( ) , true ) ; }
Send a get request and parse the result as json .
6,080
public function write ( Config $ config ) { $ pathBuildDb = Config :: KEY_BUILD . '/' . Config :: KEY_DB . '/' ; $ artifacts = $ config -> get ( Config :: KEY_DEPLOY . '/' . Config :: KEY_ARTIFACTS ) ; $ artifactsExport = '' ; foreach ( $ artifacts as $ artifactName => $ artifact ) { $ artifactVarExport = $ this -> var...
Write Config to file from Config object
6,081
public function getModelName ( ) : string { $ className = get_class ( $ this ) ; $ postfix = $ this -> getFactory ( ) -> getFactoryPostfix ( ) ; $ namespace = $ this -> getFactory ( ) -> getFactoryNamespace ( ) ; if ( $ postfix != '' ) { $ result = substr ( $ className , strlen ( $ namespace ) , strlen ( $ postfix ) * ...
Returns the model name without prefix and postfix
6,082
public function events ( ) { return [ ActiveRecord :: EVENT_AFTER_DELETE => [ $ this -> owner , 'invalidateTags' ] , ActiveRecord :: EVENT_AFTER_INSERT => [ $ this -> owner , 'invalidateTags' ] , ActiveRecord :: EVENT_AFTER_UPDATE => [ $ this -> owner , 'invalidateTags' ] , ] ; }
Get events list .
6,083
public static function getTree ( ) { $ menu = MenuItem :: orderBy ( 'lft' ) -> get ( ) ; if ( $ menu -> count ( ) ) { foreach ( $ menu as $ k => $ menu_item ) { $ menu_item -> children = collect ( [ ] ) ; foreach ( $ menu as $ i => $ menu_subitem ) { if ( $ menu_subitem -> parent_id == $ menu_item -> id ) { $ menu_item...
Get all menu items in a hierarchical collection . Only supports 2 levels of indentation .
6,084
public function export ( ) { if ( ! is_dir ( $ this -> _outputDir ) ) { mkdir ( $ this -> _outputDir , 0775 , true ) ; } foreach ( $ this -> _metadata as $ metadata ) { if ( $ output = $ this -> exportClassMetadata ( $ metadata ) ) { $ path = $ this -> _generateOutputPath ( $ metadata ) ; $ dir = dirname ( $ path ) ; i...
Exports each ClassMetadata instance to a single Doctrine Mapping file named after the entity .
6,085
protected function _generateOutputPath ( ClassMetadataInfo $ metadata ) { return $ this -> _outputDir . '/' . str_replace ( '\\' , '.' , $ metadata -> name ) . $ this -> _extension ; }
Generates the path to write the class for the given ClassMetadataInfo instance .
6,086
public static function updateBetsFromGame ( Game $ game ) { $ bets = $ game -> getBets ( ) ; $ points = $ game -> getLeague ( ) -> getPoints ( ) ; foreach ( $ bets as $ bet ) { self :: updateBetFromGame ( $ bet , $ game , $ points ) ; } }
Define bets scores for a given game
6,087
public static function betsLeft ( \ Drupal \ user \ Entity \ User $ user , Day $ day ) { $ now_date = new \ DateTime ( ) ; $ now_date -> setTimezone ( new \ DateTimeZone ( 'GMT' ) ) ; $ injected_database = Database :: getConnection ( ) ; $ subquery = $ injected_database -> select ( 'mespronos__bet' , 'b' ) ; $ subquery...
Determine number of games left to bet for a given user on a given day
6,088
public function validateMapping ( ) { $ errors = array ( ) ; $ cmf = $ this -> em -> getMetadataFactory ( ) ; $ classes = $ cmf -> getAllMetadata ( ) ; foreach ( $ classes as $ class ) { if ( $ ce = $ this -> validateClass ( $ class ) ) { $ errors [ $ class -> name ] = $ ce ; } } return $ errors ; }
Checks the internal consistency of all mapping files .
6,089
public function schemaInSyncWithMetadata ( ) { $ schemaTool = new SchemaTool ( $ this -> em ) ; $ allMetadata = $ this -> em -> getMetadataFactory ( ) -> getAllMetadata ( ) ; return count ( $ schemaTool -> getUpdateSchemaSql ( $ allMetadata , true ) ) == 0 ; }
Checks if the Database Schema is in sync with the current metadata state .
6,090
public function getExtensionByFileName ( $ filepath ) { $ path = pathinfo ( $ filepath ) ; if ( isset ( $ path [ 'extension' ] ) ) { return strtolower ( $ path [ 'extension' ] ) ; } else if ( is_string ( $ this -> getMime ( ) ) ) { return str_replace ( "image/" , "" , $ this -> getMime ( ) ) ; } else if ( $ this -> for...
A workaround to keep compatibility with Imagick when writing images to disk .
6,091
private function createBlank ( $ width , $ height ) { $ blank = imagecreatetruecolor ( $ width , $ height ) ; if ( $ this -> getMime ( ) === 'image/png' ) { imagealphablending ( $ blank , false ) ; imagesavealpha ( $ blank , true ) ; } return $ blank ; }
Helper method which returns a blank GD resource . Retains alpha for PNGs
6,092
private function fixTransparency ( $ transparency ) { $ transparency = 100 - $ transparency ; $ transparency /= 100 ; $ image = $ this -> getResource ( ) ; $ width = $ this -> getWidth ( ) ; $ height = $ this -> getHeight ( ) ; imagealphablending ( $ image , false ) ; for ( $ x = 0 ; $ x < $ width ; $ x ++ ) { for ( $ ...
Helper method in order to preserve transparency
6,093
private function columnToArray ( SimpleXMLElement $ fieldMapping ) { $ mapping = array ( 'fieldName' => ( string ) $ fieldMapping [ 'name' ] , ) ; if ( isset ( $ fieldMapping [ 'type' ] ) ) { $ mapping [ 'type' ] = ( string ) $ fieldMapping [ 'type' ] ; } if ( isset ( $ fieldMapping [ 'column' ] ) ) { $ mapping [ 'colu...
Parses the given field as array .
6,094
private function shouldReplaceSpecial ( $ buffer ) { return strpos ( $ buffer , '<pre' ) !== false || strpos ( $ buffer , '&lt;pre' ) !== false || strpos ( $ buffer , '//' ) !== false ; }
Check should special RegEx rules be applied
6,095
public function setLockMode ( $ lockMode ) { if ( in_array ( $ lockMode , array ( LockMode :: NONE , LockMode :: PESSIMISTIC_READ , LockMode :: PESSIMISTIC_WRITE ) , true ) ) { if ( ! $ this -> _em -> getConnection ( ) -> isTransactionActive ( ) ) { throw TransactionRequiredException :: transactionRequired ( ) ; } } $ ...
Set the lock mode for this Query .
6,096
public static function keepRedirectUrls ( PHPCrawlerDocumentInfo $ DocumentInfo , $ decrease_link_depths = false ) { $ cnt = count ( $ DocumentInfo -> links_found_url_descriptors ) ; for ( $ x = 0 ; $ x < $ cnt ; $ x ++ ) { if ( $ DocumentInfo -> links_found_url_descriptors [ $ x ] -> is_redirect_url == false ) { $ Doc...
Filters out all non - redirect - URLs from the URLs given in the PHPCrawlerDocumentInfo - object
6,097
public static function registerAutoloadDirectory ( $ directory ) { if ( ! class_exists ( 'Doctrine\Common\ClassLoader' , false ) ) { require_once $ directory . "/Doctrine/Common/ClassLoader.php" ; } $ loader = new ClassLoader ( "Doctrine" , $ directory ) ; $ loader -> register ( ) ; $ loader = new ClassLoader ( "Symfon...
Use this method to register all autoloads for a downloaded Doctrine library . Pick the directory the library was uncompressed into .
6,098
public static function createAnnotationMetadataConfiguration ( array $ paths , $ isDevMode = false , $ proxyDir = null , Cache $ cache = null , $ useSimpleAnnotationReader = true ) { $ config = self :: createConfiguration ( $ isDevMode , $ proxyDir , $ cache ) ; $ config -> setMetadataDriverImpl ( $ config -> newDefaul...
Creates a configuration with an annotation metadata driver .
6,099
public static function createYAMLMetadataConfiguration ( array $ paths , $ isDevMode = false , $ proxyDir = null , Cache $ cache = null ) { $ config = self :: createConfiguration ( $ isDevMode , $ proxyDir , $ cache ) ; $ config -> setMetadataDriverImpl ( new YamlDriver ( $ paths ) ) ; return $ config ; }
Creates a configuration with a yaml metadata driver .