/** * Get the widget type. * * @param \Widget $widget The widget. * * @return string * * @SuppressWarnings(PHPMD.Superglobals) */ public static function getType($widget) { $config = Spy::spyConfiguration($widget); if (isset($config['type'])) { return $config['type']; } // Try to get widget type from class if (!$widget->type) { $elements = array_flip($GLOBALS['TL_FFL']); $widgetClass = get_class($widget); if (isset($elements[$widgetClass])) { return $elements[$widgetClass]; } elseif (strpos($widgetClass, 'Contao\\') === 0) { $widgetClass = substr($widgetClass, 7); if (isset($elements[$widgetClass])) { return $elements[$widgetClass]; } } } return $widget->type; }
public function seedWithTarget() { $this->seedDb(); $spy = Spy::first(); $spy->target()->save(new Target(['name' => 'laptop'])); }
/** * Instruct this spy to return the second argument when called * * Alias for `and_return( \Spies\Spy::passed_arg( 1 ) )` * * @return Spy This Spy */ public function and_return_second_argument() { return $this->and_return(Spy::passed_arg(1)); }
/** * init the spy */ protected function initSpy() { $this->spy = Spy::instance(); }