How to use exists method of controller class

Best Atoum code snippet using controller.exists

Finance.php

Source:Finance.php Github

copy

Full Screen

...1617 // region 信息:合作公司 Company()18 public function Company()19 {20 if (method_exists('app\finance\controller\Company', 'index')) {21 $controller = controller('finance/Company', 'controller');22 return $controller->index();23 } else {24 echo $this->msg;25 }26 }2728 public function CompanyAdd()29 {30 if (method_exists('app\finance\controller\Company', 'add')) {31 $controller = controller('finance/Company', 'controller');32 return $controller->add();33 } else {34 echo $this->msg;35 }36 }3738 public function CompanyEdit()39 {40 if (method_exists('app\finance\controller\Company', 'edit')) {41 $controller = controller('finance/Company', 'controller');42 return $controller->edit();43 } else {44 echo $this->msg;45 }46 }4748 public function CompanyChangeStatus()49 {50 if (method_exists('app\finance\controller\Company', 'changeStatus')) {51 $controller = controller('finance/Company', 'controller');52 return $controller->changeStatus();53 } else {54 echo $this->msg;55 }56 }57 // endregion5859 // region 信息:资金账户 Account()60 public function Account()61 {62 if (method_exists('app\finance\controller\Account', 'index')) {63 $controller = controller('finance/Account', 'controller');64 return $controller->index();65 } else {66 echo $this->msg;67 }68 }6970 public function AccountAdd()71 {72 if (method_exists('app\finance\controller\Account', 'add')) {73 $controller = controller('finance/Account', 'controller');74 return $controller->add();75 } else {76 echo $this->msg;77 }78 }7980 public function AccountEdit()81 {82 if (method_exists('app\finance\controller\Account', 'edit')) {83 $controller = controller('finance/Account', 'controller');84 return $controller->edit();85 } else {86 echo $this->msg;87 }88 }8990 public function AccountChangeStatus()91 {92 if (method_exists('app\finance\controller\Account', 'changeStatus')) {93 $controller = controller('finance/Account', 'controller');94 return $controller->changeStatus();95 } else {96 echo $this->msg;97 }98 }99 // endregion100101 // region 信息:财务科目 AssetType()102 public function AssetType()103 {104 if (method_exists('app\finance\controller\AssetType', 'index')) {105 $controller = controller('finance/AssetType', 'controller');106 return $controller->index();107 } else {108 echo $this->msg;109 }110 }111112 public function AssetTypeAdd()113 {114 if (method_exists('app\finance\controller\AssetType', 'add')) {115 $controller = controller('finance/AssetType', 'controller');116 return $controller->add();117 } else {118 echo $this->msg;119 }120 }121122 public function AssetTypeEdit()123 {124 if (method_exists('app\finance\controller\AssetType', 'edit')) {125 $controller = controller('finance/AssetType', 'controller');126 return $controller->edit();127 } else {128 echo $this->msg;129 }130 }131132 public function AssetTypeChangeStatus()133 {134 if (method_exists('app\finance\controller\AssetType', 'changeStatus')) {135 $controller = controller('finance/AssetType', 'controller');136 return $controller->changeStatus();137 } else {138 echo $this->msg;139 }140 }141 // endregion142143 // region 信息:提成方案 CommissionRate()144 public function CommissionRate()145 {146 if (method_exists('app\finance\controller\CommissionRate', 'index')) {147 $controller = controller('finance/CommissionRate', 'controller');148 return $controller->index();149 } else {150 echo $this->msg;151 }152 }153154 public function CommissionRateAdd()155 {156 if (method_exists('app\finance\controller\CommissionRate', 'add')) {157 $controller = controller('finance/CommissionRate', 'controller');158 return $controller->add();159 } else {160 echo $this->msg;161 }162 }163164 public function CommissionRateEdit()165 {166 if (method_exists('app\finance\controller\CommissionRate', 'edit')) {167 $controller = controller('finance/CommissionRate', 'controller');168 return $controller->edit();169 } else {170 echo $this->msg;171 }172 }173174 public function CommissionRateChangeStatus()175 {176 if (method_exists('app\finance\controller\CommissionRate', 'changeStatus')) {177 $controller = controller('finance/CommissionRate', 'controller');178 return $controller->changeStatus();179 } else {180 echo $this->msg;181 }182 }183184185 public function CommissionRateLine()186 {187 if (method_exists('app\finance\controller\CommissionRate', 'line')) {188 $controller = controller('finance/CommissionRate', 'controller');189 return $controller->line();190 } else {191 echo $this->msg;192 }193 }194195 public function CommissionRateLineAdd()196 {197 if (method_exists('app\finance\controller\CommissionRate', 'lineAdd')) {198 $controller = controller('finance/CommissionRate', 'controller');199 return $controller->lineAdd();200 } else {201 echo $this->msg;202 }203 }204205 public function CommissionRateLineEdit()206 {207 if (method_exists('app\finance\controller\CommissionRate', 'lineEdit')) {208 $controller = controller('finance/CommissionRate', 'controller');209 return $controller->lineEdit();210 } else {211 echo $this->msg;212 }213 }214 // endregion215216 // region 信息:任务目标 Target()217 public function Target()218 {219 if (method_exists('app\finance\controller\Target', 'index')) {220 $controller = controller('finance/Target', 'controller');221 return $controller->index();222 } else {223 echo $this->msg;224 }225 }226227 public function TargetAdd()228 {229 if (method_exists('app\finance\controller\Target', 'add')) {230 $controller = controller('finance/Target', 'controller');231 return $controller->add();232 } else {233 echo $this->msg;234 }235 }236237 public function TargetEdit()238 {239 if (method_exists('app\finance\controller\Target', 'edit')) {240 $controller = controller('finance/Target', 'controller');241 return $controller->edit();242 } else {243 echo $this->msg;244 }245 }246247 public function TargetChangeStatus()248 {249 if (method_exists('app\finance\controller\Target', 'changeStatus')) {250 $controller = controller('finance/Target', 'controller');251 return $controller->changeStatus();252 } else {253 echo $this->msg;254 }255 }256 // endregion257258 // region 信息:收支记录 Finance()259 public function Finance()260 {261 if (method_exists('app\finance\controller\Finance', 'index')) {262 $controller = controller('finance/Finance', 'controller');263 return $controller->index();264 } else {265 echo $this->msg;266 }267 }268269 public function FinanceAdd()270 {271 if (method_exists('app\finance\controller\Finance', 'add')) {272 $controller = controller('finance/Finance', 'controller');273 return $controller->add();274 } else {275 echo $this->msg;276 }277 }278279 public function FinanceEdit()280 {281 if (method_exists('app\finance\controller\Finance', 'edit')) {282 $controller = controller('finance/Finance', 'controller');283 return $controller->edit();284 } else {285 echo $this->msg;286 }287 }288289 public function FinanceChangeStatus()290 {291 if (method_exists('app\finance\controller\Finance', 'changeStatus')) {292 $controller = controller('finance/Finance', 'controller');293 return $controller->changeStatus();294 } else {295 echo $this->msg;296 }297 }298299300 public function FinanceLine()301 {302 if (method_exists('app\finance\controller\Finance', 'line')) {303 $controller = controller('finance/Finance', 'controller');304 return $controller->line();305 } else {306 echo $this->msg;307 }308 }309310 public function FinanceLineAdd()311 {312 if (method_exists('app\finance\controller\Finance', 'lineAdd')) {313 $controller = controller('finance/Finance', 'controller');314 return $controller->lineAdd();315 } else {316 echo $this->msg;317 }318 }319320 public function FinanceLineEdit()321 {322 if (method_exists('app\finance\controller\Finance', 'lineEdit')) {323 $controller = controller('finance/Finance', 'controller');324 return $controller->lineEdit();325 } else {326 echo $this->msg;327 }328 }329330 public function FinanceLineDel()331 {332 if (method_exists('app\finance\controller\Finance', 'lineDel')) {333 $controller = controller('finance/Finance', 'controller');334 return $controller->lineDel();335 } else {336 echo $this->msg;337 }338 }339 // endregion340341 // region 信息:开票信息 Bill()342 public function Bill()343 {344 if (method_exists('app\finance\controller\Bill', 'index')) {345 $controller = controller('finance/Bill', 'controller');346 return $controller->index();347 } else {348 echo $this->msg;349 }350 }351352 public function BillAdd()353 {354 if (method_exists('app\finance\controller\Bill', 'add')) {355 $controller = controller('finance/Bill', 'controller');356 return $controller->add();357 } else {358 echo $this->msg;359 }360 }361362 public function BillEdit()363 {364 if (method_exists('app\finance\controller\Bill', 'edit')) {365 $controller = controller('finance/Bill', 'controller');366 return $controller->edit();367 } else {368 echo $this->msg;369 }370 }371372 public function BillChangeStatus()373 {374 if (method_exists('app\finance\controller\Bill', 'changeStatus')) {375 $controller = controller('finance/Bill', 'controller');376 return $controller->changeStatus();377 } else {378 echo $this->msg;379 }380 }381382383 public function BillLine()384 {385 if (method_exists('app\finance\controller\Bill', 'line')) {386 $controller = controller('finance/Bill', 'controller');387 return $controller->line();388 } else {389 echo $this->msg;390 }391 }392393 public function BillLineAdd()394 {395 if (method_exists('app\finance\controller\Bill', 'lineAdd')) {396 $controller = controller('finance/Bill', 'controller');397 return $controller->lineAdd();398 } else {399 echo $this->msg;400 }401 }402403 public function BillLineEdit()404 {405 if (method_exists('app\finance\controller\Bill', 'lineEdit')) {406 $controller = controller('finance/Bill', 'controller');407 return $controller->lineEdit();408 } else {409 echo $this->msg;410 }411 }412413414 public function BillPictureAdd()415 {416 if (method_exists('app\finance\controller\Bill', 'picture_add')) {417 $controller = controller('finance/Bill', 'controller');418 return $controller->picture_add();419 } else {420 echo $this->msg;421 }422 }423424 public function BillPictureUpload()425 {426 if (method_exists('app\finance\controller\Bill', 'picture_upload')) {427 $controller = controller('finance/Bill', 'controller');428 return $controller->picture_upload();429 } else {430 echo $this->msg;431 }432 }433434 public function BillPictureDel()435 {436 if (method_exists('app\finance\controller\Bill', 'picture_del')) {437 $controller = controller('finance/Bill', 'controller');438 return $controller->picture_del();439 } else {440 echo $this->msg;441 }442 }443444 public function BillPictureRefresh()445 {446 if (method_exists('app\finance\controller\Bill', 'picture_refresh')) {447 $controller = controller('finance/Bill', 'controller');448 return $controller->picture_refresh();449 } else {450 echo $this->msg;451 }452 }453 // endregion454455 // +----------------------------------------------------------------------456 // | 其它457 // +----------------------------------------------------------------------458459 // 科目(查询方法)460 public function getAssetType()461 {462 if (method_exists('app\finance\controller\AssetType', 'getAssetType')) {463 $controller = controller('finance/AssetType', 'controller');464 return $controller->getAssetType();465 } else {466 echo $this->msg;467 }468 } ...

Full Screen

Full Screen

Base.php

Source:Base.php Github

copy

Full Screen

...1617 // region 地域:省级信息 Province()18 public function Province()19 {20 if (method_exists('app\base\controller\Province', 'index')) {21 $controller = controller('base/Province', 'controller');22 return $controller->index();23 } else {24 echo $this->msg;25 }26 }2728 public function ProvinceAdd()29 {30 if (method_exists('app\base\controller\Province', 'add')) {31 $controller = controller('base/Province', 'controller');32 return $controller->add();33 } else {34 echo $this->msg;35 }36 }3738 public function ProvinceEdit()39 {40 if (method_exists('app\base\controller\Province', 'edit')) {41 $controller = controller('base/Province', 'controller');42 return $controller->edit();43 } else {44 echo $this->msg;45 }46 }4748 public function ProvinceChangeStatus()49 {50 if (method_exists('app\base\controller\Province', 'changeStatus')) {51 $controller = controller('base/Province', 'controller');52 return $controller->changeStatus();53 } else {54 echo $this->msg;55 }56 }57 // endregion5859 // region 地域:市级信息 City()60 public function City()61 {62 if (method_exists('app\base\controller\City', 'index')) {63 $controller = controller('base/City', 'controller');64 return $controller->index();65 } else {66 echo $this->msg;67 }68 }6970 public function CityAdd()71 {72 if (method_exists('app\base\controller\City', 'add')) {73 $controller = controller('base/City', 'controller');74 return $controller->add();75 } else {76 echo $this->msg;77 }78 }7980 public function CityEdit()81 {82 if (method_exists('app\base\controller\City', 'edit')) {83 $controller = controller('base/City', 'controller');84 return $controller->edit();85 } else {86 echo $this->msg;87 }88 }8990 public function CityChangeStatus()91 {92 if (method_exists('app\base\controller\City', 'changeStatus')) {93 $controller = controller('base/City', 'controller');94 return $controller->changeStatus();95 } else {96 echo $this->msg;97 }98 }99 // endregion100101 // region 地域:区级信息 District()102 public function District()103 {104 if (method_exists('app\base\controller\District', 'index')) {105 $controller = controller('base/District', 'controller');106 return $controller->index();107 } else {108 echo $this->msg;109 }110 }111112 public function DistrictAdd()113 {114 if (method_exists('app\base\controller\District', 'add')) {115 $controller = controller('base/District', 'controller');116 return $controller->add();117 } else {118 echo $this->msg;119 }120 }121122 public function DistrictEdit()123 {124 if (method_exists('app\base\controller\District', 'edit')) {125 $controller = controller('base/District', 'controller');126 return $controller->edit();127 } else {128 echo $this->msg;129 }130 }131132 public function DistrictChangeStatus()133 {134 if (method_exists('app\base\controller\District', 'changeStatus')) {135 $controller = controller('base/District', 'controller');136 return $controller->changeStatus();137 } else {138 echo $this->msg;139 }140 }141 // endregion142143 // region 数据:数据字典 Wordbook()144 public function Wordbook()145 {146 if (method_exists('app\base\controller\Wordbook', 'index')) {147 $controller = controller('base/Wordbook', 'controller');148 return $controller->index();149 } else {150 echo $this->msg;151 }152 }153154 public function WordbookAdd()155 {156 if (method_exists('app\base\controller\Wordbook', 'add')) {157 $controller = controller('base/Wordbook', 'controller');158 return $controller->add();159 } else {160 echo $this->msg;161 }162 }163164 public function WordbookEdit()165 {166 if (method_exists('app\base\controller\Wordbook', 'edit')) {167 $controller = controller('base/Wordbook', 'controller');168 return $controller->edit();169 } else {170 echo $this->msg;171 }172 }173174 public function WordbookChangeStatus()175 {176 if (method_exists('app\base\controller\Wordbook', 'changeStatus')) {177 $controller = controller('base/Wordbook', 'controller');178 return $controller->changeStatus();179 } else {180 echo $this->msg;181 }182 }183 // endregion184185 // region 数据:ICON图标 Icon()186 public function Icon()187 {188 if (method_exists('app\base\controller\Icon', 'index')) {189 $controller = controller('base/Icon', 'controller');190 return $controller->index();191 } else {192 echo $this->msg;193 }194 }195 // endregion196197 // +----------------------------------------------------------------------198 // | 基础数据——权限199 // +----------------------------------------------------------------------200201 // region 数据:菜单信息 Menu()202 public function Menu()203 {204 if (method_exists('app\base\controller\Menu', 'index')) {205 $controller = controller('base/Menu', 'controller');206 return $controller->index();207 } else {208 echo $this->msg;209 }210 }211212 public function MenuAdd()213 {214 if (method_exists('app\base\controller\Menu', 'add')) {215 $controller = controller('base/Menu', 'controller');216 return $controller->add();217 } else {218 echo $this->msg;219 }220 }221222 public function MenuEdit()223 {224 if (method_exists('app\base\controller\Menu', 'edit')) {225 $controller = controller('base/Menu', 'controller');226 return $controller->edit();227 } else {228 echo $this->msg;229 }230 }231232 public function MenuChangeStatus()233 {234 if (method_exists('app\base\controller\Menu', 'changeStatus')) {235 $controller = controller('base/Menu', 'controller');236 return $controller->changeStatus();237 } else {238 echo $this->msg;239 }240 }241 // endregion242243 // region 数据:特殊权限 Power()244 public function Power()245 {246 if (method_exists('app\base\controller\Power', 'index')) {247 $controller = controller('base/Power', 'controller');248 return $controller->index();249 } else {250 echo $this->msg;251 }252 }253254 public function PowerAdd()255 {256 if (method_exists('app\base\controller\Power', 'add')) {257 $controller = controller('base/Power', 'controller');258 return $controller->add();259 } else {260 echo $this->msg;261 }262 }263264 public function PowerEdit()265 {266 if (method_exists('app\base\controller\Power', 'edit')) {267 $controller = controller('base/Power', 'controller');268 return $controller->edit();269 } else {270 echo $this->msg;271 }272 }273274 public function PowerChangeStatus()275 {276 if (method_exists('app\base\controller\Power', 'changeStatus')) {277 $controller = controller('base/Power', 'controller');278 return $controller->changeStatus();279 } else {280 echo $this->msg;281 }282 }283 // endregion284285 // region 数据:组织机构 Organizational()286 public function Organizational()287 {288 if (method_exists('app\base\controller\Organizational', 'index')) {289 $controller = controller('base/Organizational', 'controller');290 return $controller->index();291 } else {292 echo $this->msg;293 }294 }295296 public function OrganizationalAdd()297 {298 if (method_exists('app\base\controller\Organizational', 'add')) {299 $controller = controller('base/Organizational', 'controller');300 return $controller->add();301 } else {302 echo $this->msg;303 }304 }305306 public function OrganizationalEdit()307 {308 if (method_exists('app\base\controller\Organizational', 'edit')) {309 $controller = controller('base/Organizational', 'controller');310 return $controller->edit();311 } else {312 echo $this->msg;313 }314 }315316 public function OrganizationalChangeStatus()317 {318 if (method_exists('app\base\controller\Organizational', 'changeStatus')) {319 $controller = controller('base/Organizational', 'controller');320 return $controller->changeStatus();321 } else {322 echo $this->msg;323 }324 }325 // endregion326327 // region 数据:角色 Role()328 public function Role()329 {330 if (method_exists('app\base\controller\Role', 'index')) {331 $controller = controller('base/Role', 'controller');332 return $controller->index();333 } else {334 echo $this->msg;335 }336 }337338 public function RoleAdd()339 {340 if (method_exists('app\base\controller\Role', 'add')) {341 $controller = controller('base/Role', 'controller');342 return $controller->add();343 } else {344 echo $this->msg;345 }346 }347348 public function RoleEdit()349 {350 if (method_exists('app\base\controller\Role', 'edit')) {351 $controller = controller('base/Role', 'controller');352 return $controller->edit();353 } else {354 echo $this->msg;355 }356 }357358 public function RoleChangeStatus()359 {360 if (method_exists('app\base\controller\Role', 'changeStatus')) {361 $controller = controller('base/Role', 'controller');362 return $controller->changeStatus();363 } else {364 echo $this->msg;365 }366 }367 // endregion368369 // region 数据:用户 User()370 public function User()371 {372 if (method_exists('app\base\controller\User', 'index')) {373 $controller = controller('base/User', 'controller');374 return $controller->index();375 } else {376 echo $this->msg;377 }378 }379380 public function UserAdd()381 {382 if (method_exists('app\base\controller\User', 'add')) {383 $controller = controller('base/User', 'controller');384 return $controller->add();385 } else {386 echo $this->msg;387 }388 }389390 public function UserEdit()391 {392 if (method_exists('app\base\controller\User', 'edit')) {393 $controller = controller('base/User', 'controller');394 return $controller->edit();395 } else {396 echo $this->msg;397 }398 }399400 public function UserSee()401 {402 if (method_exists('app\base\controller\User', 'see')) {403 $controller = controller('base/User', 'controller');404 return $controller->see();405 } else {406 echo $this->msg;407 }408 }409410 public function UserChangePassword()411 {412 if (method_exists('app\base\controller\User', 'changePassword')) {413 $controller = controller('base/User', 'controller');414 return $controller->changePassword();415 } else {416 echo $this->msg;417 }418 }419 // endregion420421 // region 数据:参数配置 Config()422 public function Config()423 {424 if (method_exists('app\base\controller\Config', 'index')) {425 $controller = controller('base/Config', 'controller');426 return $controller->index();427 } else {428 echo $this->msg;429 }430 }431432 public function ConfigEdit()433 {434 if (method_exists('app\base\controller\Config', 'edit')) {435 $controller = controller('base/Config', 'controller');436 return $controller->edit();437 } else {438 echo $this->msg;439 }440 }441442443 // endregion444445 // +----------------------------------------------------------------------446 // | 基础数据——其它447 // +----------------------------------------------------------------------448449 public function getCity()450 {451 if (method_exists('app\base\controller\City', 'getCity')) {452 $controller = controller('base/City', 'controller');453 return $controller->getCity();454 } else {455 echo $this->msg;456 }457 }458459 public function getMenuTwo()460 {461 if (method_exists('app\base\controller\Menu', 'getMenuTwo')) {462 $controller = controller('base/Menu', 'controller');463 return $controller->getMenuTwo();464 } else {465 echo $this->msg;466 }467 }468469 public function sendmailText()470 {471 if (method_exists('app\base\controller\Config', 'sendmailText')) {472 $controller = controller('base/Config', 'controller');473 return $controller->sendmailText();474 } else {475 echo $this->msg;476 }477 } ...

Full Screen

Full Screen

ControllerResolver.php

Source:ControllerResolver.php Github

copy

Full Screen

...28 * @var bool29 */30 private $supportsVariadic;31 /**32 * If scalar types exists.33 *34 * @var bool35 */36 private $supportsScalarTypes;37 public function __construct(LoggerInterface $logger = null)38 {39 $this->logger = $logger;40 $this->supportsVariadic = method_exists('ReflectionParameter', 'isVariadic');41 $this->supportsScalarTypes = method_exists('ReflectionParameter', 'getType');42 }43 /**44 * {@inheritdoc}45 *46 * This method looks for a '_controller' request attribute that represents47 * the controller name (a string like ClassName::MethodName).48 */49 public function getController(Request $request)50 {51 if (!$controller = $request->attributes->get('_controller')) {52 if (null !== $this->logger) {53 $this->logger->warning('Unable to look for the controller as the "_controller" parameter is missing.');54 }55 return false;56 }57 if (\is_array($controller)) {58 return $controller;59 }60 if (\is_object($controller)) {61 if (method_exists($controller, '__invoke')) {62 return $controller;63 }64 throw new \InvalidArgumentException(sprintf('Controller "%s" for URI "%s" is not callable.', \get_class($controller), $request->getPathInfo()));65 }66 if (\is_string($controller) && false === strpos($controller, ':')) {67 if (method_exists($controller, '__invoke')) {68 return $this->instantiateController($controller);69 } elseif (\function_exists($controller)) {70 return $controller;71 }72 }73 try {74 $callable = $this->createController($controller);75 } catch (\InvalidArgumentException $e) {76 throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable: ', $request->getPathInfo()).$e->getMessage(), 0, $e);77 }78 return $callable;79 }80 /**81 * {@inheritdoc}82 *83 * @deprecated This method is deprecated as of 3.1 and will be removed in 4.0. Implement the ArgumentResolverInterface and inject it in the HttpKernel instead.84 */85 public function getArguments(Request $request, $controller)86 {87 @trigger_error(sprintf('The "%s()" method is deprecated as of 3.1 and will be removed in 4.0. Implement the %s and inject it in the HttpKernel instead.', __METHOD__, ArgumentResolverInterface::class), E_USER_DEPRECATED);88 if (\is_array($controller)) {89 $r = new \ReflectionMethod($controller[0], $controller[1]);90 } elseif (\is_object($controller) && !$controller instanceof \Closure) {91 $r = new \ReflectionObject($controller);92 $r = $r->getMethod('__invoke');93 } else {94 $r = new \ReflectionFunction($controller);95 }96 return $this->doGetArguments($request, $controller, $r->getParameters());97 }98 /**99 * @param callable $controller100 * @param \ReflectionParameter[] $parameters101 *102 * @return array The arguments to use when calling the action103 *104 * @deprecated This method is deprecated as of 3.1 and will be removed in 4.0. Implement the ArgumentResolverInterface and inject it in the HttpKernel instead.105 */106 protected function doGetArguments(Request $request, $controller, array $parameters)107 {108 @trigger_error(sprintf('The "%s()" method is deprecated as of 3.1 and will be removed in 4.0. Implement the %s and inject it in the HttpKernel instead.', __METHOD__, ArgumentResolverInterface::class), E_USER_DEPRECATED);109 $attributes = $request->attributes->all();110 $arguments = [];111 foreach ($parameters as $param) {112 if (\array_key_exists($param->name, $attributes)) {113 if ($this->supportsVariadic && $param->isVariadic() && \is_array($attributes[$param->name])) {114 $arguments = array_merge($arguments, array_values($attributes[$param->name]));115 } else {116 $arguments[] = $attributes[$param->name];117 }118 } elseif ($this->typeMatchesRequestClass($param, $request)) {119 $arguments[] = $request;120 } elseif ($param->isDefaultValueAvailable()) {121 $arguments[] = $param->getDefaultValue();122 } elseif ($this->supportsScalarTypes && $param->hasType() && $param->allowsNull()) {123 $arguments[] = null;124 } else {125 if (\is_array($controller)) {126 $repr = sprintf('%s::%s()', \get_class($controller[0]), $controller[1]);127 } elseif (\is_object($controller)) {128 $repr = \get_class($controller);129 } else {130 $repr = $controller;131 }132 throw new \RuntimeException(sprintf('Controller "%s" requires that you provide a value for the "$%s" argument (because there is no default value or because there is a non optional argument after this one).', $repr, $param->name));133 }134 }135 return $arguments;136 }137 /**138 * Returns a callable for the given controller.139 *140 * @param string $controller A Controller string141 *142 * @return callable A PHP callable143 *144 * @throws \InvalidArgumentException When the controller cannot be created145 */146 protected function createController($controller)147 {148 if (false === strpos($controller, '::')) {149 throw new \InvalidArgumentException(sprintf('Unable to find controller "%s".', $controller));150 }151 list($class, $method) = explode('::', $controller, 2);152 if (!class_exists($class)) {153 throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class));154 }155 $controller = [$this->instantiateController($class), $method];156 if (!\is_callable($controller)) {157 throw new \InvalidArgumentException($this->getControllerError($controller));158 }159 return $controller;160 }161 /**162 * Returns an instantiated controller.163 *164 * @param string $class A class name165 *166 * @return object167 */168 protected function instantiateController($class)169 {170 return new $class();171 }172 private function getControllerError($callable)173 {174 if (\is_string($callable)) {175 if (false !== strpos($callable, '::')) {176 $callable = explode('::', $callable);177 }178 if (class_exists($callable) && !method_exists($callable, '__invoke')) {179 return sprintf('Class "%s" does not have a method "__invoke".', $callable);180 }181 if (!\function_exists($callable)) {182 return sprintf('Function "%s" does not exist.', $callable);183 }184 }185 if (!\is_array($callable)) {186 return sprintf('Invalid type for controller given, expected string or array, got "%s".', \gettype($callable));187 }188 if (2 !== \count($callable)) {189 return 'Invalid format for controller, expected [controller, method] or controller::method.';190 }191 list($controller, $method) = $callable;192 if (\is_string($controller) && !class_exists($controller)) {193 return sprintf('Class "%s" does not exist.', $controller);194 }195 $className = \is_object($controller) ? \get_class($controller) : $controller;196 if (method_exists($controller, $method)) {197 return sprintf('Method "%s" on class "%s" should be public and non-abstract.', $method, $className);198 }199 $collection = get_class_methods($controller);200 $alternatives = [];201 foreach ($collection as $item) {202 $lev = levenshtein($method, $item);203 if ($lev <= \strlen($method) / 3 || false !== strpos($item, $method)) {204 $alternatives[] = $item;205 }206 }207 asort($alternatives);208 $message = sprintf('Expected method "%s" on class "%s"', $method, $className);209 if (\count($alternatives) > 0) {210 $message .= sprintf(', did you mean "%s"?', implode('", "', $alternatives));211 } else {212 $message .= sprintf('. Available methods: "%s".', implode('", "', $collection));213 }214 return $message;215 }216 /**217 * @return bool218 */219 private function typeMatchesRequestClass(\ReflectionParameter $param, Request $request)220 {221 if (!method_exists($param, 'getType')) {222 return $param->getClass() && $param->getClass()->isInstance($request);223 }224 if (!($type = $param->getType()) || $type->isBuiltin()) {225 return false;226 }227 $class = new \ReflectionClass(method_exists($type, 'getName') ? $type->getName() : (string) $type);228 return $class && $class->isInstance($request);229 }230}...

Full Screen

Full Screen

exists

Using AI Code Generation

copy

Full Screen

1if($this->controller->exists('2.php')) {2 echo "controller exists";3} else {4 echo "controller does not exist";5}6if($this->controller->exists('1.php')) {7 echo "controller exists";8} else {9 echo "controller does not exist";10}11if($this->controller->exists('2.php', '1.php')) {12 echo "controller exists";13} else {14 echo "controller does not exist";15}16if($this->controller->exists('1.php', '2.php')) {17 echo "controller exists";18} else {19 echo "controller does not exist";20}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atoum automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in controller

Trigger exists code on LambdaTest Cloud Grid

Execute automation tests with exists on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful