Jump to content

cloing class property


Destramic

Recommended Posts

hey guys i havent done any cloneing before but what im trying to do is clone $this->_view property in my Action class and pass it to my News_Controller class so i can call the View class by a varaible and not a property....can anyone help me and give me some advise on how i should do this...i tried below but i cant get it to work...thanks alot

 

news controller class

<?php

class News_Controller extends Action
{
public function articles()
{
	$view->title = "hello";	
}
}
?>

 

action class

<?php

class Action
{
protected $_request;
protected $_response;

public $_view;

public function __construct(Request $request, Response $response)
{
	$this->set_request($request)->set_view();
	$view = $this->clone_view();
	$view->title = "hello";	
	$this->_response = $response;
}

protected function set_request(Request $request)
{
	$this->_request = $request;
	return $this;
}

protected function set_view()
{
	$this->_view = new View;
	return $this;
}

protected function get_request()
{
	return $this->_request;
}

    public function clone_view()
    {
        $view = clone $this->_view;
        return $view;
    }

public function dispatch($method, $parameters)
{	
	if ($this->get_request()->is_dispatched())
	{
		if(method_exists($this, $method))
		{
			call_user_func_array(array($this, $method), $parameters);
		}
		else 
		{

		}
	} 
}
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.