私はグーグルを使用していたでしょうが、私は外出しています。皆さんが解決策を手伝ってくれるか、戻ってくるまでに何が間違っているのか教えてくれることを願っています.
ファクトリのインスタンスをコントローラーに渡し、ファクトリを使用してコントローラーの別のインスタンスを開始したいことに基づいて、取得したこの 1 ビットに関連する
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 24 bytes) in C:\xampp\htdocs\includes\object_factory_inc.php on line 19
I'm here is here は、呼び出し元のファクトリとコントローラーです
工場
/* The purpose of this class is to create the instance of a class when needed and how needed.
For example we could have created the controller object inline but in recognition
of the polymorphic behavior of controllers we have the decided to create it in our object-
factory class(this class) which serves to hide the logic of creating the correct instance of
a specified controller.
For example the 'build_index_controller' function uses the second parameter
of the parameters passed to it to decide on the instance of the index to call
*/
class object_factory_inc
{
public function build_controller($controller_name,array $controller_params)
{
$indexed_controller_params=array_values($controller_params);
$controller_name=strtolower($controller_name);
if(!isset($indexed_controller_params[0]))
{
$controller_name=$controller_name."_controller";
return new $controller_name($this,$controller_params);
}
else
{
$controller_build_function="build_".$controller_name."_controller";
method_exists($this,$controller_build_function)?$this->$controller_build_function($controller_name,$controller_params,$indexed_controller_params):$this->controller_doesn't_exist($controller_build_function);
}
}
private function build_index_controller($controller_name,array $controller_params,array $indexed_controller_params)
{
strtolower($indexed_controller_params[0]);
switch ($indexed_controller_params[0])
{
case "s":
$controller_name=$controller_name."_search_controller";
return new $controller_name($this,$controller_params);
break;
case "admin":
$controller_name=$controller_name."_admin_controller";
return new $controller_name($this,$controller_params);
break;
case "loggedin":
$controller_name=$controller_name."_loggedin_controller";
return new $controller_name($this,$controller_params);
break;
default://if it doesn't exist just run default controller behaviour consider running 404
$controller_name=$controller_name."_controller";
return $controller_name($this,$controller_params);
}
}
private function controller_doesnt_exist($controller_name)
{
echo "404 error ".$controller_name." doesn't exist on this server";
}
}
実行しようとしているコントローラー:
class index_controller
{
protected $parameters=array();
protected $default_operation='view';
protected $object_factory;
public function __construct(object_factory_inc $factory,array $parameters )
{
$this->object_factory=$factory;
$this->parameters=$parameters;
$this->varify_controller();
//print_r($parameters);
//var_dump($factory);
//require_once "views/index_view.php";
}
private function varify_controller()
{
if(true)//if logged in session is set;
{
$indexd_parameteres=array_values($this->parameters);
$indexd_parameteres[0]='loggedin';
$this->object_factory->build_controller("index",$this->parameters);
}
}
}
the normal way the controllers are usually called are from the index here it is
require_once 'includes/config.php';
$route=isset($_GET['action'])?new router_controller($_GET['action']):new router_controller($_GET['action']="/index");
$route->parse_route();
$object_factory=new object_factory_inc;
$controller=$object_factory->build_controller($route->get_controller(),$route->get_request_data());
長い質問で申し訳ありませんが、事前に必要なものをすべて提供したかったので、もし私が何か完全に間違ったことをしている場合は、私をグーグルに誘導するつもりなら、少なくともグーグルに何かを与えてください。