<?php
namespace Application\Model;
use Interop\Container\ContainerInterface;
use Laminas\ServiceManager\Factory\AbstractFactoryInterface;
class CommonModelTableFactory implements AbstractFactoryInterface
{
public function canCreate(ContainerInterface $container, $requestedName)
{
return ((substr($requestedName, -5) === 'Table') && class_exists($requestedName));
}
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
$tableModel = '\\' . $requestedName;
$adapter = $container->get('Laminas\Db\Adapter\Adapter');
return new $tableModel($adapter);
}
}
Welcome to the forums!
In the chat you have written a different error message:
Parse error: syntax error, unexpected 'class' (T_CLASS) in
C:\xampp\htdocs\laminas\module\Application\src\Factory\CommonControllerFactory.php
on line 7
So the given class CommonModelTableFactory
is not the problem.
Yes I solved it as the error was on common controller factory
Great and thanks for the feedback!
1 Like