idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
58,700
|
public static function shorten ( $ url ) { $ client = new Client ( ) ; $ request = $ client -> get ( self :: $ _BITLY_URL ) ; $ request -> getQuery ( ) -> add ( 'access_token' , self :: $ _ACCESS_KEY ) ; $ request -> getQuery ( ) -> add ( 'longUrl' , $ url ) ; $ resp = $ request -> send ( ) ; $ jsonRep = $ resp -> json ( ) ; return $ jsonRep [ 'data' ] [ 'url' ] ; }
|
Shortens a URL to a bit . ly url
|
58,701
|
public function fetchRepository ( Repository $ repository ) { $ response = $ this -> getResponse ( sprintf ( '%s/%s/metrics' , $ repository -> getType ( ) , $ repository -> getSlug ( ) ) ) ; if ( ! $ response || isset ( $ repositoryArray [ 'error' ] ) ) { throw new \ UnexpectedValueException ( sprintf ( 'Response is empty for url %s' , $ response ) ) ; } $ repository = $ this -> hydrate ( $ repository , $ response [ 'values' ] ) ; $ repository -> setBranch ( $ response [ 'branch' ] ) ; return $ repository ; }
|
Fetch data from repository URL
|
58,702
|
public static function run ( $ app ) { $ route = Router :: process ( new Request ) ; if ( ! class_exists ( $ route [ 'controller' ] ) or ! method_exists ( $ route [ 'controller' ] , "{$route['method']}Action" ) ) { if ( $ app -> environment ( ) == 'development' ) { throw new Exception ( "Unable to find controller for '" . Request :: pathInfo ( ) . "'" ) ; } else { $ route = Router :: set404 ( ) ; } } $ r = new ReflectionMethod ( "{$route['controller']}::{$route['method']}Action" ) ; $ params = [ ] ; foreach ( $ r -> getParameters ( ) as $ param ) { if ( isset ( $ route [ 'params' ] [ $ param -> getName ( ) ] ) ) { $ params [ ] = $ route [ 'params' ] [ $ param -> getName ( ) ] ; } } unset ( $ r , $ param ) ; static :: $ controller = new $ route [ 'controller' ] ( ) ; $ beforeAll = EventDispatcher :: dispatch ( "before." . $ route [ 'controller' ] . "::*" ) ; $ beforeAction = EventDispatcher :: dispatch ( "before." . $ route [ 'controller' ] . "::{$route['method']}" ) ; if ( $ beforeAll instanceof Response || $ beforeAction instanceof Response ) { static :: $ controller -> executeAction = false ; $ response = $ beforeAll ? : $ beforeAction ; } if ( static :: $ controller -> executeAction ) { $ response = call_user_func_array ( array ( static :: $ controller , $ route [ 'method' ] . 'Action' ) , $ params ) ; } $ afterAll = EventDispatcher :: dispatch ( "after." . $ route [ 'controller' ] . "::*" ) ; $ afterAction = EventDispatcher :: dispatch ( "after." . $ route [ 'controller' ] . "::{$route['method']}" ) ; if ( $ afterAll instanceof Response || $ afterAction instanceof Response ) { $ response = $ afterAll instanceof Response ? $ afterAll : $ afterAction ; } if ( ! $ response instanceof Response ) { throw new Exception ( "The controller [{$route['controller']}::{$route['method']}] returned an invalid response." ) ; } else { $ response -> send ( ) ; } static :: $ controller -> __shutdown ( ) ; }
|
Runs the application and routes the request .
|
58,703
|
public function listAction ( $ person_id , Request $ request ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ person = $ em -> getRepository ( 'ChillPersonBundle:Person' ) -> find ( $ person_id ) ; $ this -> denyAccessUnlessGranted ( 'CHILL_PERSON_SEE' , $ person ) ; $ reachableScopes = $ this -> get ( 'chill.main.security.authorization.helper' ) -> getReachableScopes ( $ this -> getUser ( ) , new Role ( 'CHILL_REPORT_SEE' ) , $ person -> getCenter ( ) ) ; $ reports = $ em -> getRepository ( 'ChillReportBundle:Report' ) -> findBy ( array ( 'person' => $ person , 'scope' => $ reachableScopes ) ) ; return $ this -> render ( 'ChillReportBundle:Report:list.html.twig' , array ( 'reports' => $ reports , 'person' => $ person ) ) ; }
|
List all the report entities for a given person .
|
58,704
|
public function selectReportTypeAction ( $ person_id , Request $ request ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ person = $ em -> getRepository ( 'ChillPersonBundle:Person' ) -> find ( $ person_id ) ; if ( $ person === NULL ) { throw $ this -> createNotFoundException ( 'Person not found!' ) ; } $ this -> denyAccessUnlessGranted ( 'CHILL_PERSON_SEE' , $ person , 'access denied for person view' ) ; $ this -> denyAccessUnlessGranted ( 'CHILL_REPORT_CREATE' , ( new Report ( ) ) -> setPerson ( $ person ) , 'access denied for report creation' ) ; $ cFGroupId = $ request -> query -> get ( 'cFGroup' ) ; if ( $ cFGroupId ) { return $ this -> redirect ( $ this -> generateUrl ( 'report_new' , array ( 'person_id' => $ person_id , 'cf_group_id' => $ cFGroupId ) ) ) ; } $ cFGroups = $ em -> getRepository ( 'ChillCustomFieldsBundle:CustomFieldsGroup' ) -> findByEntity ( 'Chill\ReportBundle\Entity\Report' ) ; if ( count ( $ cFGroups ) === 1 ) { return $ this -> redirect ( $ this -> generateUrl ( 'report_new' , array ( 'person_id' => $ person_id , 'cf_group_id' => $ cFGroups [ 0 ] -> getId ( ) ) ) ) ; } $ cFGroupsChoice = array ( ) ; foreach ( $ cFGroups as $ cFGroup ) { $ cFGroupsChoice [ $ cFGroup -> getId ( ) ] = $ cFGroup -> getName ( $ request -> getLocale ( ) ) ; } $ form = $ this -> get ( 'form.factory' ) -> createNamedBuilder ( null , 'form' , null , array ( 'method' => 'GET' , 'csrf_protection' => false ) ) -> add ( 'cFGroup' , 'choice' , array ( 'choices' => $ cFGroupsChoice ) ) -> getForm ( ) ; $ person = $ em -> getRepository ( 'ChillPersonBundle:Person' ) -> find ( $ person_id ) ; return $ this -> render ( 'ChillReportBundle:Report:select_report_type.html.twig' , array ( 'form' => $ form -> createView ( ) , 'person' => $ person ) ) ; }
|
Display a form for selecting which type of report to add for a given person
|
58,705
|
public function exportAction ( $ cf_group_id , Request $ request ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ cFGroup = $ em -> getRepository ( 'ChillCustomFieldsBundle:CustomFieldsGroup' ) -> find ( $ cf_group_id ) ; $ reports = $ em -> getRepository ( 'ChillReportBundle:Report' ) -> findByCFGroup ( $ cFGroup ) ; $ response = $ this -> render ( 'ChillReportBundle:Report:export.csv.twig' , array ( 'reports' => $ reports , 'cf_group' => $ cFGroup ) ) ; $ response -> headers -> set ( 'Content-Type' , 'text/csv; charset=utf-8' ) ; $ response -> headers -> set ( 'Content-Disposition' , 'attachment; filename="export.csv"' ) ; return $ response ; }
|
Return a csv file with all the reports of a given type
|
58,706
|
public function newAction ( $ person_id , $ cf_group_id , Request $ request ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ person = $ em -> getRepository ( 'ChillPersonBundle:Person' ) -> find ( $ person_id ) ; $ cFGroup = $ em -> getRepository ( 'ChillCustomFieldsBundle:CustomFieldsGroup' ) -> find ( $ cf_group_id ) ; if ( $ person === NULL ) { throw $ this -> createNotFoundException ( "Person not found" ) ; } $ this -> denyAccessUnlessGranted ( 'CHILL_PERSON_SEE' , $ person ) ; $ this -> denyAccessUnlessGranted ( 'CHILL_REPORT_CREATE' , ( new Report ( ) ) -> setPerson ( $ person ) , 'access denied for report creation' ) ; if ( $ cFGroup === NULL ) { throw $ this -> createNotFoundException ( "custom fields group not found" ) ; } $ entity = new Report ( ) ; $ entity -> setUser ( $ this -> get ( 'security.context' ) -> getToken ( ) -> getUser ( ) ) ; $ entity -> setDate ( new \ DateTime ( 'now' ) ) ; $ entity -> setCFGroup ( $ cFGroup ) ; $ form = $ this -> createCreateForm ( $ entity , $ person , $ cFGroup ) ; return $ this -> render ( 'ChillReportBundle:Report:new.html.twig' , array ( 'entity' => $ entity , 'form' => $ form -> createView ( ) , 'person' => $ person ) ) ; }
|
Display a form for creating a new report for a given person and of a given type
|
58,707
|
public function createAction ( $ person_id , $ cf_group_id , Request $ request ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ entity = new Report ( ) ; $ cFGroup = $ em -> getRepository ( 'ChillCustomFieldsBundle:CustomFieldsGroup' ) -> find ( $ cf_group_id ) ; $ person = $ em -> getRepository ( 'ChillPersonBundle:Person' ) -> find ( $ person_id ) ; if ( $ person === NULL || $ cFGroup === NULL ) { throw $ this -> createNotFoundException ( ) ; } $ this -> denyAccessUnlessGranted ( 'CHILL_PERSON_SEE' , $ person ) ; $ form = $ this -> createCreateForm ( $ entity , $ person , $ cFGroup ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ entity -> setCFGroup ( $ cFGroup ) ; $ entity -> setPerson ( $ person ) ; $ this -> denyAccessUnlessGranted ( 'CHILL_REPORT_CREATE' , $ entity ) ; $ em -> persist ( $ entity ) ; $ em -> flush ( ) ; $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , $ this -> get ( 'translator' ) -> trans ( 'Success : report created!' ) ) ; return $ this -> redirect ( $ this -> generateUrl ( 'report_view' , array ( 'person_id' => $ person_id , 'report_id' => $ entity -> getId ( ) ) ) ) ; } $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'error' , $ this -> get ( 'translator' ) -> trans ( 'The form is not valid. The report has not been created !' ) ) ; return $ this -> render ( 'ChillReportBundle:Report:new.html.twig' , array ( 'entity' => $ entity , 'form' => $ form -> createView ( ) , 'person' => $ person ) ) ; }
|
Create a new report for a given person and of a given type
|
58,708
|
private function createCreateForm ( Report $ entity , Person $ person , $ cFGroup ) { $ form = $ this -> createForm ( 'chill_reportbundle_report' , $ entity , array ( 'action' => $ this -> generateUrl ( 'report_create' , array ( 'person_id' => $ person -> getId ( ) , 'cf_group_id' => $ cFGroup -> getId ( ) ) ) , 'method' => 'POST' , 'cFGroup' => $ cFGroup , 'role' => new Role ( 'CHILL_REPORT_CREATE' ) , 'center' => $ person -> getCenter ( ) ) ) ; return $ form ; }
|
Creates a form to create a Report entity .
|
58,709
|
public function viewAction ( $ report_id , $ person_id ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ person = $ em -> getRepository ( 'ChillPersonBundle:Person' ) -> find ( $ person_id ) ; $ entity = $ em -> getRepository ( 'ChillReportBundle:Report' ) -> find ( $ report_id ) ; if ( ! $ entity || ! $ person ) { throw $ this -> createNotFoundException ( $ this -> get ( 'translator' ) -> trans ( 'Unable to find this report.' ) ) ; } $ this -> denyAccessUnlessGranted ( 'CHILL_REPORT_SEE' , $ entity ) ; return $ this -> render ( 'ChillReportBundle:Report:view.html.twig' , array ( 'entity' => $ entity , 'person' => $ person , ) ) ; }
|
Find and display a report .
|
58,710
|
public function editAction ( $ person_id , $ report_id , Request $ request ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ report = $ em -> getRepository ( 'ChillReportBundle:Report' ) -> find ( $ report_id ) ; if ( ! $ report ) { throw $ this -> createNotFoundException ( $ this -> get ( 'translator' ) -> trans ( 'Unable to find this report.' ) ) ; } if ( intval ( $ person_id ) !== intval ( $ report -> getPerson ( ) -> getId ( ) ) ) { throw new \ RuntimeException ( $ this -> get ( 'translator' ) -> trans ( 'This is not the report of the person.' ) , 1 ) ; } $ this -> denyAccessUnlessGranted ( 'CHILL_REPORT_UPDATE' , $ report ) ; $ person = $ report -> getPerson ( ) ; $ editForm = $ this -> createEditForm ( $ report ) ; return $ this -> render ( 'ChillReportBundle:Report:edit.html.twig' , array ( 'edit_form' => $ editForm -> createView ( ) , 'person' => $ person , ) ) ; }
|
Display a form to edit an existing Report entity .
|
58,711
|
private function createEditForm ( Report $ entity ) { $ form = $ this -> createForm ( 'chill_reportbundle_report' , $ entity , array ( 'action' => $ this -> generateUrl ( 'report_update' , array ( 'person_id' => $ entity -> getPerson ( ) -> getId ( ) , 'report_id' => $ entity -> getId ( ) ) ) , 'method' => 'PUT' , 'cFGroup' => $ entity -> getCFGroup ( ) , 'role' => new Role ( 'CHILL_REPORT_UPDATE' ) , 'center' => $ entity -> getPerson ( ) -> getCenter ( ) ) ) ; return $ form ; }
|
Creates a form to edit a Report entity .
|
58,712
|
public function updateAction ( $ person_id , $ report_id , Request $ request ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ report = $ em -> getRepository ( 'ChillReportBundle:Report' ) -> find ( $ report_id ) ; if ( ! $ report ) { throw $ this -> createNotFoundException ( $ this -> get ( 'translator' ) -> trans ( 'Unable to find this report.' ) ) ; } $ this -> denyAccessUnlessGranted ( 'CHILL_REPORT_UPDATE' , $ report ) ; $ editForm = $ this -> createEditForm ( $ report ) ; $ editForm -> handleRequest ( $ request ) ; if ( $ editForm -> isValid ( ) ) { $ em -> flush ( ) ; $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , $ this -> get ( 'translator' ) -> trans ( 'Success : report updated!' ) ) ; return $ this -> redirect ( $ this -> generateUrl ( 'report_view' , array ( 'person_id' => $ report -> getPerson ( ) -> getId ( ) , 'report_id' => $ report_id ) ) ) ; } $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'error' , $ this -> get ( 'translator' ) -> trans ( 'The form is not valid. The report has not been updated !' ) ) ; return $ this -> render ( 'ChillReportBundle:Report:edit.html.twig' , array ( 'edit_form' => $ editForm -> createView ( ) , 'person' => $ report -> getPerson ( ) ) ) ; }
|
Web page for editing an existing report .
|
58,713
|
public static function factory ( StyleType $ type ) : Style { return self :: evaluate ( $ type ) -> isInstanceOf ( Style :: class ) -> getValue ( ) ; }
|
Crea objetos Style
|
58,714
|
protected function configure ( ) : void { $ this -> register ( 'makeType' ) ; $ this -> register ( 'makeValue' ) ; $ this -> register ( 'makeArgument' ) ; $ this -> register ( 'makeStrong' ) ; $ this -> register ( 'makeExceptionHeader' ) ; $ this -> register ( 'makeExceptionBody' ) ; $ this -> register ( 'makeExceptionTrace' ) ; $ this -> register ( 'makeEmpty' ) ; }
|
Configura esta factoria
|
58,715
|
public function makeArgument ( StyleType $ type ) : ? Style { if ( ! $ type -> isArgument ( ) ) { return null ; } return Style :: make ( ) -> setFgColor ( Color :: YELLOW ( ) ) ; }
|
Devuelte un style de tipo argument
|
58,716
|
public function makeStrong ( StyleType $ type ) : ? Style { if ( ! $ type -> isStrong ( ) ) { return null ; } return Style :: make ( ) -> bold ( ) -> underscore ( ) ; }
|
Devuelte un style de tipo strong
|
58,717
|
public function makeExceptionHeader ( StyleType $ type ) : ? Style { if ( ! $ type -> isExceptionHeader ( ) ) { return null ; } return Style :: make ( ) -> setBgColor ( Color :: RED ( ) ) -> setFgColor ( Color :: WHITE ( ) ) -> bold ( ) -> margin ( 2 ) -> padding ( 2 ) -> align ( Align :: CENTER ( ) ) ; }
|
Devuelte un style de tipo exception_header
|
58,718
|
public function makeExceptionBody ( StyleType $ type ) : ? Style { if ( ! $ type -> isExceptionBody ( ) ) { return null ; } return Style :: make ( ) -> margin ( 2 ) ; }
|
Devuelte un style de tipo exception_body
|
58,719
|
public function makeExceptionTrace ( StyleType $ type ) : ? Style { if ( ! $ type -> isExceptionTrace ( ) ) { return null ; } return Style :: make ( ) -> setFgColor ( Color :: GREEN ( ) ) -> margin ( 2 ) ; }
|
Devuelte un style de tipo exception_trace
|
58,720
|
public function onSitemapNodeEdit ( SitemapNodeEvent $ event ) { $ node = $ event -> getNode ( ) ; if ( in_array ( $ node -> getType ( ) , $ this -> textNodeTypes ) ) { $ tab = new Tab ( $ event -> getTranslator ( ) -> trans ( 'text' , array ( ) , 'SilvestraTextNodeBundle' ) , 'silvestra_text_node' , $ event -> getRouter ( ) -> generate ( 'silvestra_text_node' , array ( '_format' => 'json' , 'nodeId' => $ node -> getId ( ) ) ) ) ; $ event -> addTab ( $ tab ) ; } }
|
On edit node .
|
58,721
|
public function onSitemapNodeDelete ( TreeNodeEvent $ event ) { $ node = $ event -> getNode ( ) ; if ( TextNodeInterface :: NODE_TYPE === $ node -> getType ( ) ) { $ this -> nodeHandler -> onDeleteNode ( $ node ) ; } }
|
On sitemap node delete .
|
58,722
|
public function query ( $ query ) { if ( strtoupper ( substr ( PHP_OS , 0 , 3 ) ) === 'WIN' ) { return $ this -> connection -> ExecQuery ( $ query ) ; } else { $ execString = $ this -> connectionString . '"' . $ query . '"' ; $ aReturn = Array ( ) ; $ inc = $ wmiout = $ execstatus = null ; exec ( $ execString , $ wmiout , $ execstatus ) ; $ wmiCount = count ( $ wmiout ) ; if ( $ wmiCount > 0 ) { $ names = explode ( '|' , $ wmiout [ 1 ] ) ; for ( $ i = 2 ; $ i < $ wmiCount ; $ i ++ ) { $ data = explode ( '|' , $ wmiout [ $ i ] ) ; $ j = 0 ; $ inc = $ i - 2 ; $ aReturn [ $ inc ] = new \ stdClass ( ) ; foreach ( $ data as $ item ) { $ jIndex = $ j ++ ; if ( isset ( $ names [ $ jIndex ] ) ) { $ objName = $ names [ $ jIndex ] ; $ aReplace = array ( ':' , '_' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' ) ; $ aReplace2 = array ( '(null)' , 'True' , 'False' ) ; $ preparedData = str_replace ( $ aReplace2 , array ( null , true , false ) , str_replace ( $ aReplace , ' ' , $ item ) ) ; $ aReturn [ $ inc ] -> $ objName = $ preparedData ; } else { $ j = $ jIndex - 1 ; } } } } $ stdObjReturn = ( object ) $ aReturn ; return $ stdObjReturn ; } }
|
Executes the specified query on the current connection .
|
58,723
|
public static function pluralize ( $ word ) { $ lowerCasedWord = strtolower ( $ word ) ; foreach ( static :: $ uncountables as $ uncountable ) { if ( substr ( $ lowerCasedWord , ( - 1 * strlen ( $ uncountable ) ) ) == $ uncountable ) { return $ word ; } } foreach ( static :: $ irregulars as $ plural => $ singular ) { if ( preg_match ( '/(' . $ plural . ')$/i' , $ word , $ arr ) ) { return preg_replace ( '/(' . $ plural . ')$/i' , substr ( $ arr [ 0 ] , 0 , 1 ) . substr ( $ singular , 1 ) , $ word ) ; } } foreach ( static :: $ plurals as $ rule => $ replacement ) { if ( preg_match ( $ rule , $ word ) ) { return preg_replace ( $ rule , $ replacement , $ word ) ; } } return false ; }
|
Pluralizes English noun .
|
58,724
|
public static function singularize ( $ word ) { static :: $ uncountables = array ( 'equipment' , 'information' , 'rice' , 'money' , 'species' , 'series' , 'fish' , 'sheep' , 'media' ) ; static :: $ irregulars = array ( 'person' => 'people' , 'man' => 'men' , 'child' => 'children' , 'sex' => 'sexes' , 'move' => 'moves' ) ; $ lowerCasedWord = strtolower ( $ word ) ; foreach ( static :: $ uncountables as $ uncountable ) { if ( substr ( $ lowerCasedWord , ( - 1 * strlen ( $ uncountable ) ) ) == $ uncountable ) { return $ word ; } } foreach ( static :: $ irregulars as $ plural => $ singular ) { if ( preg_match ( '/(' . $ singular . ')$/i' , $ word , $ arr ) ) { return preg_replace ( '/(' . $ singular . ')$/i' , substr ( $ arr [ 0 ] , 0 , 1 ) . substr ( $ plural , 1 ) , $ word ) ; } } foreach ( static :: $ singulars as $ rule => $ replacement ) { if ( preg_match ( $ rule , $ word ) ) { return preg_replace ( $ rule , $ replacement , $ word ) ; } } return $ word ; }
|
Singularizes English plural .
|
58,725
|
public function setGithubOAuthToken ( $ token , $ domain = 'github.com' ) { $ this -> set ( self :: GITHUB_OAUTH_KEY . '/' . $ this -> escape ( $ domain ) , $ token ) ; return $ this ; }
|
Set a github OAuth token .
|
58,726
|
public function removeGithubOAuthToken ( $ domain = 'github.com' ) { $ this -> remove ( self :: GITHUB_OAUTH_KEY . '/' . $ this -> escape ( $ domain ) ) ; return $ this ; }
|
Unset a github OAuth token .
|
58,727
|
public function setGitlabOAuthToken ( $ token , $ domain = 'gitlab.com' ) { $ this -> set ( self :: GITLAB_OAUTH_KEY . '/' . $ this -> escape ( $ domain ) , $ token ) ; return $ this ; }
|
Set a gitlab OAuth token .
|
58,728
|
public function removeGitlabOAuthToken ( $ domain = 'gitlab.com' ) { $ this -> remove ( self :: GITLAB_OAUTH_KEY . '/' . $ this -> escape ( $ domain ) ) ; return $ this ; }
|
Unset a gitlab OAuth token .
|
58,729
|
public function setGitlabPrivateToken ( $ token , $ domain = 'gitlab.com' ) { $ this -> set ( self :: GITLAB_PRIVATE_KEY . '/' . $ this -> escape ( $ domain ) , $ token ) ; return $ this ; }
|
Set a gitlab private token .
|
58,730
|
public function removeGitlabPrivateToken ( $ domain = 'gitlab.com' ) { $ this -> remove ( self :: GITLAB_PRIVATE_KEY . '/' . $ this -> escape ( $ domain ) ) ; return $ this ; }
|
Unset a gitlab private token .
|
58,731
|
public function setBitbucketOAuth ( $ key , $ secret , $ domain = 'bitbucket.org' ) { $ this -> set ( self :: BITBUCKET_OAUTH_KEY . '/' . $ this -> escape ( $ domain ) , [ 'consumer-key' => $ key , 'consumer-secret' => $ secret ] ) ; return $ this ; }
|
Set Bitbucket OAuth .
|
58,732
|
public function removeBitbucketOAuth ( $ domain = 'bitbucket.org' ) { $ this -> remove ( self :: BITBUCKET_OAUTH_KEY . '/' . $ this -> escape ( $ domain ) ) ; return $ this ; }
|
Unset a Bitbucket token .
|
58,733
|
public function setHttpBasic ( $ username , $ password , $ domain ) { $ this -> set ( self :: HTTP_BASIC_KEY . '/' . $ this -> escape ( $ domain ) , [ 'username' => $ username , 'password' => $ password ] ) ; return $ this ; }
|
Set http - basic auth .
|
58,734
|
public function removeHttpBasic ( $ domain ) { $ this -> remove ( self :: HTTP_BASIC_KEY . '/' . $ this -> escape ( $ domain ) ) ; return $ this ; }
|
Unset http - basic auth .
|
58,735
|
public function markComplete ( $ calcId ) { $ dateEnded = $ this -> hlpDate -> getUtcNowForDb ( ) ; $ bind = [ ECalculation :: A_DATE_ENDED => $ dateEnded , ECalculation :: A_STATE => Cfg :: CALC_STATE_COMPLETE ] ; $ result = $ this -> updateById ( $ calcId , $ bind ) ; return $ result ; }
|
Mark calculation as complete .
|
58,736
|
public static function patchTags ( $ ids , $ tag ) { assert ( is_array ( $ ids ) || $ ids === 'all' ) ; $ fields = [ 'action' => 'reassign_tag' , 'data' => [ 'subscribers' => $ ids , 'tag' => $ tag ] ] ; Yii :: $ app -> mailtankClient -> sendRequest ( self :: ENDPOINT , json_encode ( $ fields ) , 'patch' ) ; return true ; }
|
Reassigns tag to specified subscribers
|
58,737
|
public function validateOperator ( $ operator ) { $ operators = Operator :: get ( ) ; if ( in_array ( $ operator , $ operators ) ) return true ; $ message = "Operator: $operator is invalid, and cannot be used." ; throw new InvalidOperatorException ( $ message ) ; }
|
Validates the operator in an expression .
|
58,738
|
public function boot ( ) { if ( null === $ this -> service ) { throw new \ LogicException ( 'You must setup a ServiceInterface' ) ; } foreach ( $ this -> service -> getStatuses ( ) as $ status ) { $ hasToContinue = false ; foreach ( $ this -> filters as $ filter ) { if ( ! $ filter -> isValid ( $ status ) ) { $ hasToContinue = true ; break ; } } if ( $ hasToContinue ) { continue ; } foreach ( $ this -> formatters as $ formatter ) { $ status = $ formatter -> format ( $ status ) ; } $ this -> stream -> addStatus ( $ status ) ; } $ this -> isBooted = true ; return $ this ; }
|
Fetch datas filter and format them .
|
58,739
|
public static function loadFile ( $ fileName ) { if ( ! preg_match ( '/\.ini$/i' , $ fileName ) ) { $ fileName .= '.ini' ; } if ( ! static :: isFileLoaded ( $ fileName ) ) { self :: $ files [ ] = $ fileName ; return static :: loadFileInMemory ( $ fileName ) ; } return false ; }
|
Charge un nouveau fichier de langue .
|
58,740
|
public function check ( ) { $ action = $ this -> request -> param ( 'action' ) ; $ controller = $ this -> request -> param ( 'controller' ) ; $ prefix = ( $ this -> request -> param ( 'prefix' ) === false ) ? '/' : $ this -> request -> param ( 'prefix' ) ; $ plugin = ( $ this -> request -> param ( 'plugin' ) === false ) ? '' : $ this -> request -> param ( 'plugin' ) ; $ plugin_prefix = ( empty ( $ plugin ) ) ? $ prefix : $ plugin . '.' . $ prefix ; if ( isset ( $ this -> _authorized [ $ plugin_prefix ] [ $ controller ] ) && in_array ( $ action , $ this -> _authorized [ $ plugin_prefix ] [ $ controller ] ) ) return true ; $ user_id = $ this -> request -> session ( ) -> read ( 'Auth.User.id' ) ; $ group_id = - 1 ; if ( isset ( $ this -> controllers [ 'group' ] ) ) { $ User = TableRegistry :: get ( $ this -> controllers [ 'user' ] ) ; $ group_id = $ User -> get ( $ user_id ) -> group_id ; } $ UserGroupPermission = TableRegistry :: get ( 'UserGroupPermission' ) ; $ Permission = TableRegistry :: get ( 'Permission' ) ; $ unique_string = $ this -> getUniqueString ( $ controller , $ action , $ prefix , $ plugin ) ; $ permission_id = $ Permission -> find ( ) -> select ( [ 'id' ] ) -> where ( [ 'unique_string' => $ unique_string ] ) -> first ( ) ; if ( is_null ( $ permission_id ) ) return false ; $ allow = $ UserGroupPermission -> find ( ) -> select ( [ 'allow' ] ) -> where ( [ 'group_or_user' => 'user' , 'group_or_user_id' => $ user_id , ] ) -> orWhere ( [ 'group_or_user' => 'group' , 'group_or_user_id' => $ group_id ] ) -> andWhere ( [ 'permission_id' => $ permission_id -> id ] ) -> order ( [ 'allow' => 'DESC' ] ) -> first ( ) ; if ( is_null ( $ allow ) ) return false ; return $ allow -> allow ; }
|
Checks whether the user or group is allowed access
|
58,741
|
private function getUniqueString ( $ controller , $ action , $ prefix = false , $ plugin = false ) { $ unique_string = '' ; if ( $ plugin && ! empty ( $ plugin ) ) $ unique_string .= $ plugin . '.' ; if ( $ prefix && $ prefix != '/' ) $ unique_string .= $ prefix ; return $ unique_string . '/' . $ controller . '->' . $ action ; }
|
Create unique string acl
|
58,742
|
public function newAction ( ) { $ entity = new ProductOrderStatus ( ) ; $ form = $ this -> createCreateForm ( $ entity ) ; return array ( 'entity' => $ entity , 'form' => $ form -> createView ( ) , ) ; }
|
Displays a form to create a new ProductOrderStatus entity .
|
58,743
|
public function commit ( UncommittedEvents $ events ) { $ aggregateId = ( string ) $ events [ 0 ] -> getAggregateIdentity ( ) ; $ stream = fopen ( $ this -> dataPath . '/' . $ aggregateId , 'a' ) ; $ i = 0 ; foreach ( $ events as $ event ) { $ content = ( $ i > 0 ) ? PHP_EOL : '' ; $ content .= serialize ( $ event ) ; fwrite ( $ stream , $ content ) ; $ i ++ ; } fclose ( $ stream ) ; }
|
Serialize given events and save them do disk . Actually each event is a new line inside a single file for each aggregate
|
58,744
|
public function getMappedAttributes ( ) { $ mappedArrayForApiRequest = [ ] ; $ requestAttributes = $ this -> request -> getData ( ) ; foreach ( $ requestAttributes as $ key => $ value ) { if ( array_key_exists ( $ key , $ this -> mappingRequestToOtherRequestAttributes ) ) { $ mappedArrayForApiRequest [ $ this -> mappingRequestToOtherRequestAttributes [ $ key ] ] = $ value ; } } return $ mappedArrayForApiRequest ; }
|
Get mapped array from the request attributes to the other attributes
|
58,745
|
public function init ( $ dbConfig ) { $ profiler = new Profiler ( ) ; if ( isset ( $ this -> drivers [ $ dbConfig [ 'driver' ] ] ) ) { $ driverClass = $ this -> drivers [ $ dbConfig [ 'driver' ] ] ; self :: $ driverInstance = $ driverClass :: getInstance ( ) ; $ profiler -> getTimer ( ) -> start ( ) ; self :: $ driverInstance -> setup ( $ dbConfig ) ; $ profilerOptions = [ 'type' => 'connection' , 'time' => $ profiler -> getTimer ( ) -> calculate ( ) ] ; $ profiler -> setOptions ( 'dbConnection' , $ profilerOptions ) ; Safan :: handler ( ) -> getObjectManager ( ) -> setObject ( 'gapOrmProfiler' , $ profiler ) ; } else { throw new DriverNotFound ( $ dbConfig [ 'driver' ] ) ; } }
|
Connect to driver
|
58,746
|
public function overlay ( $ message , $ title = 'Notice' ) { $ this -> message ( $ message , $ title ) ; $ this -> session -> flash ( 'flash_notification.overlay' , true ) ; return $ this ; }
|
Flash an overlay modal .
|
58,747
|
public static function check_token ( $ value = null ) { $ value = $ value ? : \ Input :: param ( static :: $ csrf_token_key , \ Input :: json ( static :: $ csrf_token_key , 'fail' ) ) ; if ( static :: fetch_token ( ) == static :: $ csrf_old_token and ! empty ( $ value ) ) { static :: set_token ( true ) ; } return $ value === static :: $ csrf_old_token ; }
|
Check CSRF Token
|
58,748
|
public static function generate_token ( ) { $ token_base = time ( ) . uniqid ( ) . \ Config :: get ( 'security.token_salt' , '' ) . mt_rand ( 0 , mt_getrandmax ( ) ) ; if ( function_exists ( 'hash_algos' ) and in_array ( 'sha512' , hash_algos ( ) ) ) { $ token = hash ( 'sha512' , $ token_base ) ; } else { $ token = md5 ( $ token_base ) ; } return $ token ; }
|
Generate new token . Based on an example from OWASP
|
58,749
|
public function setException ( $ path ) { $ pathException = ( ! is_array ( $ path ) ) ? array ( $ path ) : $ path ; $ this -> exceptions = array_merge ( $ this -> exceptions , $ pathException ) ; }
|
Add a variable name for an exception
|
58,750
|
public function setRestriction ( $ path ) { $ pathRestriction = ( ! is_array ( $ path ) ) ? array ( $ path ) : $ path ; $ this -> restrctions = array_merge ( $ this -> restrctions , $ pathRestriction ) ; }
|
Add a path to restrict the checking to
|
58,751
|
public function run ( Config $ configuration ) { $ this -> config = $ configuration ; $ this -> config -> set ( 'base' , str_replace ( 'app.php' , '' , $ _SERVER [ 'SCRIPT_NAME' ] ) ) ; try { $ request = $ this -> getRequest ( ) ; if ( ! $ this -> config -> get ( 'routes' ) ) { throw new Exception404 ( "No routes" , 1 ) ; } else { list ( $ controller_name , $ action_name , $ parameters ) = $ this -> findRoute ( $ request ) ; } $ controller = new $ controller_name ( ) ; $ controller -> $ action_name ( $ parameters ) ; } catch ( Exception404 $ e ) { $ e -> displayMessage ( ) ; } }
|
Executes application .
|
58,752
|
protected function findRoute ( $ request_id ) { $ routes = $ this -> config -> get ( 'routes' ) ; foreach ( $ routes as $ pattern => $ action ) { $ pattern = '/^' . $ pattern . '$/' ; if ( preg_match ( $ pattern , $ request_id , $ parameters ) ) { $ chunks = explode ( '::' , $ action ) ; $ controller_name = $ chunks [ 0 ] ; $ action_name = isset ( $ chunks [ 1 ] ) ? $ chunks [ 1 ] : 'index' ; return array ( $ controller_name , $ action_name , $ this -> cleanParameters ( $ parameters ) ) ; } } throw new Exception404 ( "Invalid request '$request_id'" ) ; }
|
Finds the route for the current path .
|
58,753
|
protected function cleanParameters ( array $ parameters ) { foreach ( $ parameters as $ parameter => $ value ) { if ( is_int ( $ parameter ) ) { unset ( $ parameters [ $ parameter ] ) ; } } return $ parameters ; }
|
Clean parameters from integer keys .
|
58,754
|
public static function isBodyAllowed ( $ code ) { if ( ! isset ( self :: $ codesDescriptions [ $ code ] ) ) { throw new InvalidArgumentException ( "Invalid code $code specified" ) ; } return ( $ code >= self :: OK && $ code !== self :: NO_CONTENT && $ code !== self :: NOT_MODIFIED ) ; }
|
Provides information if provided code allow to contain body .
|
58,755
|
public function execute ( ) { $ resultPage = $ this -> _resultPageFactory -> create ( ) ; $ resultPage -> setActiveMenu ( 'WorldnetTPS_SecureCard::securecard_list' ) ; $ resultPage -> getConfig ( ) -> getTitle ( ) -> prepend ( __ ( 'WorldNetTPS SecureCard' ) ) ; return $ resultPage ; }
|
Grid List page .
|
58,756
|
public static function build ( $ name , $ type ) { $ factory = new BuildFactory ( self :: config ( $ name ) , $ type ) ; $ buildNode = $ factory -> build ( ) ; $ buildNode -> build ( ) ; return $ buildNode -> getNodes ( ) ; }
|
API for build node
|
58,757
|
public static function generate ( $ name , $ properties ) { $ factory = new GenerateFactory ( self :: config ( $ name ) , $ properties ) ; $ generateNode = $ factory -> generate ( ) ; $ generateNode -> generate ( ) ; return $ generateNode ; }
|
API for generate node
|
58,758
|
public function getById ( $ id , $ cascade = false ) { $ result = self :: getField ( $ this -> data , $ id , null ) ; if ( $ cascade && null !== $ result && isset ( $ this -> one [ $ id ] ) ) { foreach ( $ this -> one [ $ id ] as $ class => $ foreignId ) { $ result = array_merge ( $ class :: getInstance ( ) -> getById ( $ foreignId , $ cascade ) , $ result ) ; } } return $ result ; }
|
Gets data by id
|
58,759
|
public function getAllWhichHasOne ( $ foreignId , JSONSimpleStorage $ object , $ cascade = false ) { $ result = [ ] ; if ( isset ( $ object -> many [ $ foreignId ] [ $ this -> class ] ) ) { foreach ( $ object -> many [ $ foreignId ] [ $ this -> class ] as $ id ) { if ( null !== ( $ item = $ this -> getById ( $ id , $ cascade ) ) ) { $ result [ $ id ] = $ item ; } } } return $ result ; }
|
Gets all records which has one object
|
58,760
|
public function hasOne ( $ id , JSONSimpleStorage $ object , $ foreignId ) { if ( ! isset ( $ this -> one [ $ id ] ) ) { $ this -> one [ $ id ] = [ ] ; } if ( ! isset ( $ object -> many [ $ foreignId ] ) ) { $ object -> many [ $ foreignId ] = [ ] ; $ object -> many [ $ foreignId ] [ $ this -> class ] = [ ] ; } else if ( ! isset ( $ object -> many [ $ foreignId ] [ $ this -> class ] ) ) { $ object -> many [ $ foreignId ] [ $ this -> class ] = [ ] ; } $ this -> one [ $ id ] [ $ object -> class ] = $ foreignId ; if ( ! in_array ( $ id , $ object -> many [ $ foreignId ] [ $ this -> class ] ) ) { $ object -> many [ $ foreignId ] [ $ this -> class ] [ ] = $ id ; } self :: $ dirty [ $ object -> class ] = true ; self :: $ dirty [ $ this -> class ] = true ; }
|
Sets relation has one
|
58,761
|
public function hasMany ( $ id , \ JSONSimpleStorage $ object , array $ foreignIds ) { foreach ( $ foreignIds as $ foreignId ) { $ object -> hasOne ( $ foreignId , $ this , $ id ) ; } }
|
Sets has many relation
|
58,762
|
private function store ( ) { file_put_contents ( $ this -> getFilename ( ) , json_encode ( [ self :: FIELD_IDGEN => $ this -> idGen , self :: FIELD_DATA => $ this -> data , self :: FIELD_MANY => $ this -> many , self :: FIELD_ONE => $ this -> one , ] ) ) ; }
|
Stores data in file
|
58,763
|
public function captureStart ( EventInterface $ event ) { ++ $ this -> index ; $ time = microtime ( true ) ; $ eventName = $ event -> getName ( ) ; if ( $ eventName ) { $ this -> timers [ $ eventName ] = [ 'start' => $ time , 'stop' => $ time ] ; return ; } $ this -> timers [ $ this -> index ] = [ 'start' => $ time , 'stop' => $ time ] ; }
|
Fixes the event start time .
|
58,764
|
public function captureStop ( EventInterface $ event ) { $ time = microtime ( true ) ; $ eventName = $ event -> getName ( ) ; if ( $ eventName && isset ( $ this -> timers [ $ eventName ] ) ) { $ this -> timers [ $ eventName ] [ 'stop' ] = $ time ; return ; } $ this -> timers [ $ this -> index ] [ 'stop' ] = $ time ; }
|
Fixes the event stop time .
|
58,765
|
public function readFile ( $ filename ) { if ( ! is_string ( $ filename ) ) throw new IniReadingException ( 'The expected type is string' ) ; if ( ! file_exists ( $ filename ) || ! is_readable ( $ filename ) ) throw new IniReadingException ( sprintf ( "The file %s doesn't exist or is not readable" , $ filename ) ) ; if ( function_exists ( 'file_get_contents' ) ) { $ ini = file_get_contents ( $ filename ) ; } elseif ( function_exists ( 'file' ) ) { $ ini = file ( $ filename ) ; if ( $ ini !== false ) $ ini = implode ( "\n" , $ ini ) ; } elseif ( function_exists ( 'fopen' ) && function_exists ( 'fread' ) ) { $ handle = fopen ( $ filename , 'r' ) ; if ( ! $ handle ) return false ; $ ini = fread ( $ handle , filesize ( $ filename ) ) ; fclose ( $ handle ) ; } else { return false ; } if ( $ ini === false ) throw new IniReadingException ( sprintf ( 'Impossible to read the file %s' , $ filename ) ) ; return $ this -> readString ( $ ini ) ; }
|
Parse INI file .
|
58,766
|
public function readString ( $ string ) { if ( ! is_string ( $ string ) ) throw new IniReadingException ( 'The expected type is string' ) ; $ string .= "\n" ; $ data = @ parse_ini_string ( $ string , true ) ; if ( $ data === false ) { $ e = error_get_last ( ) ; throw new IniReadingException ( 'Syntax error in INI configuration: ' . $ e [ 'message' ] ) ; } $ rawValues = @ parse_ini_string ( $ string , true , INI_SCANNER_RAW ) ; return $ this -> toCollection ( $ this -> decode ( $ data , $ rawValues ) ) ; }
|
Parse INI string .
|
58,767
|
private function toCollection ( array $ array ) { $ collection = new IniCollection ( [ ] ) ; foreach ( $ array as $ k => $ v ) { if ( is_array ( $ array [ $ k ] ) ) $ collection -> set ( $ k , $ this -> toCollection ( $ array [ $ k ] ) -> toArray ( ) ) ; else $ collection -> set ( $ k , $ v ) ; } return $ collection ; }
|
Transform array to IniCollection .
|
58,768
|
private function decode ( $ data , $ raw ) { if ( is_array ( $ data ) ) { foreach ( $ data as $ k => & $ v ) { $ v = $ this -> decode ( $ v , $ raw [ $ k ] ) ; } return $ data ; } $ data = $ this -> decodeBoolean ( $ data , $ raw ) ; $ data = $ this -> decodeNull ( $ data , $ raw ) ; if ( is_numeric ( $ data ) && ( ( string ) ( $ data + 0 ) === $ data ) ) return $ data + 0 ; if ( is_string ( $ raw ) && empty ( $ raw ) ) return "" ; return $ data ; }
|
Detect and decode all value .
|
58,769
|
private function decodeBoolean ( $ data , $ rawValue ) { if ( $ data === '1' && ( $ rawValue === 'true' || $ rawValue === 'on' || $ rawValue === 'yes' ) ) return true ; elseif ( ( $ data === '0' || empty ( $ data ) ) && ( $ rawValue === 'false' || $ rawValue === 'off' || $ rawValue === 'no' ) ) return false ; return $ data ; }
|
Detect and decode boolean value .
|
58,770
|
public function detectChanges ( ) { $ this -> signalDispatcher -> connect ( FlowFileMonitor :: class , 'filesHaveChanged' , function ( string $ fileMonitorIdentifier , array $ changedFiles ) { if ( $ fileMonitorIdentifier === static :: FILE_MONITOR_IDENTIFIER ) { foreach ( $ changedFiles as $ changedFile => $ status ) { if ( $ status === ChangeDetectionStrategyInterface :: STATUS_DELETED ) { $ this -> unmonitorFile ( $ changedFile ) ; $ this -> emitFileHasChanged ( $ changedFile ) ; } if ( $ status === ChangeDetectionStrategyInterface :: STATUS_CHANGED ) { $ this -> emitFileHasChanged ( $ changedFile ) ; } } } } ) ; $ fileMonitor = new FlowFileMonitor ( static :: FILE_MONITOR_IDENTIFIER ) ; $ files = $ this -> cache -> getByTag ( 'file' ) ; foreach ( $ files as $ file ) { $ fileMonitor -> monitorFile ( $ file ) ; } $ fileMonitor -> detectChanges ( ) ; $ fileMonitor -> shutdownObject ( ) ; }
|
Detects react file changes
|
58,771
|
private function compilePath ( RouteInterface $ route , array $ parameters , $ host , $ type , $ name ) { if ( static :: RELATIVE_PATH === $ type && null !== $ route -> getHost ( ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Can\'t create relative path because route "%s" requires a deticated hostname.' , $ name ) ) ; } $ context = $ route -> getContext ( ) ; $ prefix = static :: ABSOLUTE_PATH === $ type ? $ this -> getPathPrefix ( $ route , $ host ) : '' ; if ( 0 === count ( $ vars = $ context -> getVars ( ) ) ) { return $ this -> getPrefixed ( $ context -> getStaticPath ( ) , $ prefix ) ; } $ parts = [ ] ; $ vars = $ this -> getRouteVars ( $ context , $ parameters ) ; foreach ( $ context -> getTokens ( ) as $ token ) { if ( $ token instanceof Variable ) { if ( $ token -> required && ! isset ( $ vars [ $ token -> value ] ) ) { throw new \ InvalidArgumentException ( sprintf ( '{%s} is a required parameter.' , $ token -> getValue ( ) ) ) ; } $ parts [ ] = $ vars [ $ token -> value ] ; } else { $ parts [ ] = $ token -> value ; } } return $ this -> getPrefixed ( implode ( '' , $ parts ) , $ prefix ) ; }
|
Compiles a Route instance into a readable path or url .
|
58,772
|
public function add ( $ event ) { $ event -> setParent ( $ this -> _parent ) ; $ this -> _events [ $ event -> getName ( ) ] = $ event ; }
|
add an event to he pile
|
58,773
|
public function destroy ( $ name ) { if ( isset ( $ this -> _events [ $ name ] ) ) { unset ( $ this -> _events [ $ name ] ) ; $ this -> _events = array_values ( $ this -> _events ) ; } }
|
destroy an event
|
58,774
|
public function getResult ( $ name = '' ) { $ result = [ ] ; if ( $ name != '' ) { if ( isset ( $ this -> _events [ $ name ] ) ) { return $ this -> _events [ $ name ] -> getResult ( ) ; } else { return false ; } } else { foreach ( $ this -> _events as $ events ) { $ result [ $ events -> getName ( ) ] = $ events -> getResult ( ) ; } return $ result ; } }
|
get result returned by the listener
|
58,775
|
public function setStatus ( $ name = '' , $ status = self :: START ) { if ( $ name != '' ) { if ( isset ( $ this -> _events [ $ name ] ) ) { $ this -> _events [ $ name ] -> setStatus ( $ status ) ; return true ; } else { return false ; } } else { return false ; } }
|
set the status
|
58,776
|
public function getStatus ( $ name = '' ) { if ( $ name != '' ) { if ( isset ( $ this -> _events [ $ name ] ) ) { return $ this -> _events [ $ name ] -> getStatus ( ) ; } else { return false ; } } else { return false ; } }
|
get the status of the event
|
58,777
|
public function removeElement ( $ element ) { $ key = array_search ( $ element , $ this -> getArrayCopy ( ) ) ; if ( false !== $ key ) { $ this -> remove ( $ key ) ; } }
|
Remove object from the collection
|
58,778
|
public function sendReconfirmationMessage ( User $ user , Token $ token ) { if ( $ token -> type == Token :: TYPE_CONFIRM_NEW_EMAIL ) { $ email = $ user -> unconfirmedEmail ; } else { $ email = $ user -> email ; } return $ this -> sendMessage ( $ email , $ this -> getReconfirmationSubject ( ) , 'reconfirmation' , [ 'user' => $ user , 'token' => $ token ] ) ; }
|
Sends an email to a user with reconfirmation link .
|
58,779
|
public function actionUpdate ( $ id ) { Url :: remember ( '' , 'actions-redirect' ) ; $ user = $ this -> findModel ( $ id ) ; $ user -> scenario = User :: SCENARIO_UPDATE ; $ event = $ this -> getUserEvent ( $ user ) ; $ this -> performAjaxValidation ( $ user ) ; $ this -> trigger ( self :: EVENT_BEFORE_UPDATE , $ event ) ; if ( $ user -> load ( Yii :: $ app -> request -> post ( ) ) && $ user -> save ( ) ) { Yii :: $ app -> getSession ( ) -> setFlash ( 'success' , Yii :: t ( 'users' , 'Account details have been updated' ) ) ; $ this -> trigger ( self :: EVENT_AFTER_UPDATE , $ event ) ; return $ this -> refresh ( ) ; } return $ this -> render ( '_account' , [ 'user' => $ user , ] ) ; }
|
Updates an existing User model .
|
58,780
|
public function actionConfirm ( $ id ) { $ model = $ this -> findModel ( $ id ) ; $ event = $ this -> getUserEvent ( $ model ) ; $ this -> trigger ( self :: EVENT_BEFORE_CONFIRM , $ event ) ; $ model -> confirm ( ) ; $ this -> trigger ( self :: EVENT_AFTER_CONFIRM , $ event ) ; Yii :: $ app -> getSession ( ) -> setFlash ( 'success' , Yii :: t ( 'users' , 'User has been confirmed' ) ) ; return $ this -> redirect ( Url :: previous ( 'actions-redirect' ) ) ; }
|
Confirms the User .
|
58,781
|
protected function performAjaxValidation ( $ model ) { if ( Yii :: $ app -> request -> isAjax && ! Yii :: $ app -> request -> isPjax ) { if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) ) { Yii :: $ app -> response -> format = Response :: FORMAT_JSON ; echo json_encode ( ActiveForm :: validate ( $ model ) ) ; Yii :: $ app -> end ( ) ; } } }
|
Performs AJAX validation .
|
58,782
|
private function applyPatch ( $ patches ) : void { $ homeDir = $ this -> parameters -> get ( 'dotfiles.home_dir' ) ; $ this -> debug ( 'start applying patch to ' . $ homeDir ) ; $ fs = new Filesystem ( ) ; foreach ( $ patches as $ relPath => $ patch ) { $ contents = implode ( PHP_EOL , $ patch ) ; $ target = $ homeDir . DIRECTORY_SEPARATOR . $ relPath ; $ this -> debug ( '+patch ' . $ target ) ; Toolkit :: ensureFileDir ( $ target ) ; $ fs -> patch ( $ target , $ contents ) ; } }
|
Processing all registered patch .
|
58,783
|
public function indexAction ( ) { $ jobManager = $ this -> get ( 'phlexible_queue.job_manager' ) ; $ data = [ ] ; foreach ( $ jobManager -> findAll ( ) as $ job ) { $ data [ ] = [ 'id' => $ job -> getId ( ) , 'command' => $ job -> getCommand ( ) , 'arguments' => implode ( ' ' , $ job -> getArguments ( ) ) , 'priority' => $ job -> getPriority ( ) , 'status' => $ job -> getStatus ( ) , ] ; } $ out = '<pre>Current jobs: ' . PHP_EOL ; $ out .= print_r ( $ data , 1 ) ; return new Response ( $ out ) ; }
|
Return queue status .
|
58,784
|
public function getDir ( ) { if ( $ this -> dir === null ) { $ rc = new \ ReflectionClass ( $ this ) ; $ this -> dir = dirname ( $ rc -> getFileName ( ) ) ; } return $ this -> dir ; }
|
Retuns the module directory
|
58,785
|
public function setResource ( $ id , $ resource ) { if ( ! ( $ resource instanceof Redis ) ) { throw new ArchException ( 'Not a valid redis resource' ) ; } $ this -> resources [ ( string ) $ id ] = [ 'persistent_id' => '' , 'lib_options' => [ ] , 'server' => [ ] , 'password' => '' , 'database' => 0 , 'resource' => $ resource , 'initialized' => true , 'version' => 0 , ] ; return $ this ; }
|
Set a resource
|
58,786
|
public static function getPaddingPluginManager ( ) { if ( static :: $ paddingPlugins === null ) { self :: setPaddingPluginManager ( new \ Zend \ Crypt \ Symmetric \ PaddingPluginManager ( ) ) ; } return static :: $ paddingPlugins ; }
|
Returns the padding plugin manager . If it doesn t exist it s created .
|
58,787
|
public static function setPaddingPluginManager ( $ plugins ) { if ( is_string ( $ plugins ) ) { if ( ! class_exists ( $ plugins ) ) { throw new \ Cityware \ Exception \ InvalidArgumentException ( sprintf ( 'Unable to locate padding plugin manager via class "%s"; class does not exist' , $ plugins ) ) ; } $ plugins = new $ plugins ( ) ; } if ( ! $ plugins instanceof \ Zend \ Crypt \ Symmetric \ PaddingPluginManager ) { throw new \ Cityware \ Exception \ InvalidArgumentException ( sprintf ( 'Padding plugins must extend %s\PaddingPluginManager; received "%s"' , __NAMESPACE__ , ( is_object ( $ plugins ) ? get_class ( $ plugins ) : gettype ( $ plugins ) ) ) ) ; } static :: $ paddingPlugins = $ plugins ; }
|
Set the padding plugin manager
|
58,788
|
public function getKeySize ( ) { return mcrypt_get_key_size ( $ this -> supportedAlgos [ $ this -> algo ] , $ this -> supportedModes [ $ this -> mode ] ) ; }
|
Get the maximum key size for the selected cipher and mode of operation
|
58,789
|
public function getKey ( ) { if ( empty ( $ this -> key ) ) { return null ; } return substr ( $ this -> key , 0 , $ this -> getKeySize ( ) ) ; }
|
Get the encryption key
|
58,790
|
public function setPadding ( \ Zend \ Crypt \ Symmetric \ Padding \ PaddingInterface $ padding ) { $ this -> padding = $ padding ; return $ this ; }
|
Set the padding object
|
58,791
|
public function getCipherDataSalt ( $ data ) { if ( empty ( $ data ) ) { throw new \ Cityware \ Exception \ InvalidArgumentException ( 'The data to decrypt cannot be empty' ) ; } else { $ cipherData = base64_decode ( $ data ) ; } return substr ( $ cipherData , 0 , $ this -> getSaltSize ( ) ) ; }
|
Get the original salt value
|
58,792
|
public function setMode ( $ mode ) { if ( ! empty ( $ mode ) ) { $ mode = strtolower ( $ mode ) ; if ( ! array_key_exists ( $ mode , $ this -> supportedModes ) ) { throw new \ Cityware \ Exception \ InvalidArgumentException ( "The mode $mode is not supported by " . __CLASS__ ) ; } $ this -> mode = $ mode ; } return $ this ; }
|
Set the cipher mode
|
58,793
|
public function getBlockSize ( ) { return mcrypt_get_block_size ( $ this -> supportedAlgos [ $ this -> algo ] , $ this -> supportedModes [ $ this -> mode ] ) ; }
|
Get the block size
|
58,794
|
protected function _normalizeIterator ( $ iterable ) { if ( $ iterable instanceof stdClass ) { $ iterable = ( array ) $ iterable ; } if ( ! is_array ( $ iterable ) && ! ( $ iterable instanceof Traversable ) ) { throw $ this -> _createInvalidArgumentException ( $ this -> __ ( 'Invalid iterable' ) , null , null , $ iterable ) ; } if ( $ iterable instanceof Iterator ) { return $ iterable ; } if ( is_array ( $ iterable ) ) { return $ this -> _createArrayIterator ( $ iterable ) ; } return $ this -> _createTraversableIterator ( $ iterable ) ; }
|
Normalizes an iterable value into an iterator .
|
58,795
|
public function mockService ( $ service , $ singleton = true ) { $ mock = \ Mockery :: mock ( $ service ) -> makePartial ( ) ; $ this -> getContainer ( ) -> add ( $ service , $ mock , $ singleton ) ; return $ mock ; }
|
Mock service and add to container
|
58,796
|
public function get ( $ name ) { $ command = $ this -> driver -> factoryCommand ( 'cookie' , WebDriver_Command :: METHOD_GET ) ; $ value = $ this -> driver -> curl ( $ command ) [ 'value' ] ; $ search = array_filter ( $ value , function ( $ item ) use ( $ name ) { return ( $ item [ 'name' ] == $ name ) ; } ) ; $ search = array_values ( $ search ) ; $ value = empty ( $ search ) ? null : $ search [ 0 ] ; if ( $ value ) { $ value = new WebDriver_Object_Cookie_CookieInfo ( $ value ) ; } return $ value ; }
|
Retrieve one cookie visible to the current page .
|
58,797
|
public function getAll ( ) { $ command = $ this -> driver -> factoryCommand ( 'cookie' , WebDriver_Command :: METHOD_GET ) ; $ all = $ this -> driver -> curl ( $ command ) [ 'value' ] ; $ result = [ ] ; foreach ( $ all as $ value ) { $ result [ $ value [ 'value' ] ] = new WebDriver_Object_Cookie_CookieInfo ( $ value ) ; } return $ result ; }
|
Retrieve all cookies visible to the current page .
|
58,798
|
public function delete ( $ name ) { $ command = $ this -> driver -> factoryCommand ( "cookie/{$name}" , WebDriver_Command :: METHOD_DELETE ) ; $ this -> driver -> curl ( $ command ) ; }
|
Delete the cookie with the given name .
|
58,799
|
public function clearAll ( ) { $ command = $ this -> driver -> factoryCommand ( 'cookie' , WebDriver_Command :: METHOD_DELETE ) ; $ this -> driver -> curl ( $ command ) ; }
|
Delete all cookies visible to the current page .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.