2013-08-17 19:20:23 -04:00
|
|
|
<?php
|
|
|
|
|
2014-04-15 22:25:48 -03:00
|
|
|
namespace DesignPatterns\Behavioral\Visitor;
|
2013-08-17 19:20:23 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Visitor Pattern
|
|
|
|
*
|
2013-08-17 19:41:18 -04:00
|
|
|
* An implementation of a concrete Visitor
|
2013-08-17 19:20:23 -04:00
|
|
|
*/
|
2013-09-12 11:20:10 +02:00
|
|
|
class RolePrintVisitor implements RoleVisitorInterface
|
2013-08-17 19:20:23 -04:00
|
|
|
{
|
2013-08-17 19:41:18 -04:00
|
|
|
/**
|
2013-09-12 11:20:10 +02:00
|
|
|
* {@inheritdoc}
|
2013-08-17 19:41:18 -04:00
|
|
|
*/
|
2013-08-17 19:20:23 -04:00
|
|
|
public function visitGroup(Group $role)
|
|
|
|
{
|
|
|
|
echo "Role: " . $role->getName();
|
|
|
|
}
|
|
|
|
|
2013-08-17 19:41:18 -04:00
|
|
|
/**
|
2013-09-12 11:20:10 +02:00
|
|
|
* {@inheritdoc}
|
2013-08-17 19:41:18 -04:00
|
|
|
*/
|
2013-08-17 19:20:23 -04:00
|
|
|
public function visitUser(User $role)
|
|
|
|
{
|
|
|
|
echo "Role: " . $role->getName();
|
|
|
|
}
|
|
|
|
}
|