Zend framework dojo select dojo.byid exception Object #<HTMLTableElement> has no method 'attr' - zend-framework

I'm trying to get the selected value of my select.
The select element is renderd by Zend Framework Forms I set the attribute
'data-dojo-type' to'dijit/form/Select'
and try to access it with:
require(["dojo/ready"], function(ready){
ready(function(){
ServerID = dojo.byId('ElementID').attr('value');
});
});
Chrome keeps tellinge me:
Uncaught TypeError: Object #<HTMLTableElement> has no method 'attr'
Greetings clemo.

I think this should be
ServerID = dojo.attr('ElementID', 'value');

Related

TYPO3 v9.5.0 - Bootstrap Package url error message

I have a TYPO3 9.5.0LTS and use the bootstrap package theme. It seems to be all working ... I defined the site configuration and then I get nice looking urls ... but quite often I get such error messages:
Core: Exception handler (WEB): Uncaught TYPO3 Exception: #1436717266: Invalid header value for header "Expire"". The value must be a string or an array of strings. | InvalidArgumentException thrown in file /is/www/typo3_src-9.5.0/typo3/sysext/core/Classes/Http/Message.php in line 208. Requested URL: domain/content-examples/media/audio
What causes this and how to prevent this?
Edit: Might be this part in TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::getHttpHeadersForTemporaryContent() on line 4244:
/**
* Returns HTTP headers for temporary content.
* These headers prevent search engines from caching temporary content and asks them to revisit this page again.
* Please ensure to also send a 503 HTTP Status code with these headers.
*/
protected function getHttpHeadersForTemporaryContent(): array
{
return [
'Retry-after' => '3600',
'Pragma' => 'no-cache',
'Cache-control' => 'no-cache',
'Expire' => 0,
];
}
... so I change it to 'Expires' => 0
https://forge.typo3.org/issues/86651#change-388813
It seems there's a typo in "Expire" header, should be "Expires".
Try to change it in:
TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::getHttpHeadersForTemporaryContent()
while they're fixing this problem
UPD
TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController, line 4244
'Expire' => 0,
change to
'Expires' => '0',
https://forge.typo3.org/issues/86658
And correct header name should be 'Expires' afaik:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Expires
I think to change the file:
typo3_src-9.5.0/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
on line 4244 from
'Expire' => 0,
to
'Expire' => '0',
helps. The issue is reported https://forge.typo3.org/issues/86658 and will be changed with the next update, I am sure.

How to fix error "Cannot dispatch middleware Application\Middleware\IndexMiddleware"?

I've set up a Zend Application as normal, except in my case the difference is that I set it up over an existing legacy web application.
I still want to call my existing legacy application over the ZF3 app. It was suggested I can do so using Middleware. I went over https://docs.zendframework.com/zend-mvc/middleware/ and set up my routing as described there.
However, when I run the application, I am greeted by this:
Cannot dispatch middleware Application\Middleware\IndexMiddleware
#0 zend-mvc\src\MiddlewareListener.php(146):
Zend\Mvc\Exception\InvalidMiddlewareException::fromMiddlewareName('Application\\Mid...')
Here is where the exception happens:
https://github.com/zendframework/zend-mvc/blob/release-3.1.0/src/MiddlewareListener.php#L146
Just to note:
$middlewareToBePiped; //'Application\Middleware\IndexMiddleware'
is_string($middlewareToBePiped); // true
$serviceLocator->has($middlewareToBePiped);//false
$middlewareToBePiped instanceof MiddlewareInterface; //false
is_callable($middlewareToBePiped);//false
My class is:
namespace Application\Middleware;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Interop\Http\ServerMiddleware\MiddlewareInterface;
use Interop\Http\ServerMiddleware\DelegateInterface;
use Zend\Http\Response;
class IndexMiddleware implements MiddlewareInterface
{
public function __invoke(ServerRequestInterface $request, ResponseInterface $response)
{}
public function process(ServerRequestInterface $request, DelegateInterface $delegate)
{}
}
I am thinking that my issue is that my IndexMiddleware class is not being found in ServiceLocator... (line 142 of linked API). How do I get it in there?
I put this into my application.config.php file:
'service_manager' => [
'invokables' => array(
'middleware' => IndexMiddleware::class
)
]
onto the next error it is.. (Last middleware executed did not return a response.)
but looks like it has executed)

Invalid controller using custom routes

I've been following the instruction on how to create custom routes from the book Zend Framework - A Beginners Guide
I've changed my application.ini file to include this routing information:
resources.router.routes.static-content.route = /content/:page
resources.router.routes.static-content.defaults.module = default
resources.router.routes.static-content.defaults.controller = static-content
resources.router.routes.static-content.defaults.view = static-content
resources.router.routes.static-content.defaults.action = display
Given the above configuration, I have this controller:
<?php
class Default_StaticContentController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}
public function displayAction()
{
// action body
$page = $this->getRequest()->getParam('page');
if (file_exists($this->view->getScriptPath(null) .
'/' . $this->getRequest()->getControllerName() . '/' .
$page . $this->viewSuffix
)) {
$this->render($page);
}
else {
throw new Zend_Controller_Action_Exception('HLC - Page not found', 404);
}
}
}
I have a view named about.phtml in the APPLICATION_PATH/modules/default/views/static-content folder.
What ahppens is I get an error saying:
An error occurred
Page not found
Exception information:
Message: Invalid controller class ("StaticContentController")
Stack trace:
#0 /Applications/MAMP/htdocs/zend/library/Zend/Controller/Dispatcher/Standard.php(262): Zend_Controller_Dispatcher_Standard->loadClass('StaticContentCo...')
#1 /Applications/MAMP/htdocs/zend/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#2 /Applications/MAMP/htdocs/zend/library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch()
#3 /Applications/MAMP/htdocs/zend/library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#4 /Applications/MAMP/htdocs/HLC/public/index.php(26): Zend_Application->run()
#5 {main}
Request Parameters:
array (
'page' => 'about',
'module' => 'default',
'controller' => 'static-content',
'view' => 'static-content',
'action' => 'display',
)
Note that it is not rendering my customised Zend_Controller_Action_Exception but throwing the global error.
I'm using the URL: http://hlc.local:8888/content/about
The default index action works ok, just this routing that's not working.
if you are actually following the book closely, you have an extra line in your route declaration and your controller class should be StaticContentController.
here is the route definition from the book that does work.
resources.router.routes.static-content.route = /content/:page
resources.router.routes.static-content.defaults.module = default
resources.router.routes.static-content.defaults.controller = static-content
resources.router.routes.static-content.defaults.action = display
I still have this code laying around from last summer.
I found this book less then satisfactory and not really for beginners. It fails to address the Zend_Db component opting instead to introduce Doctrine 1.2. It's seems to be a trend that a number of these beginner/easy books feel that a full ORM is more useful then Zend_Db. If you are already familiar with Doctrine this approach works fine, otherwise it's a lot to ask of a beginner, to learn ZF and Doctrine at the same time.
Hope this helps.
I don't now what you use for autoloading. so that would helpful to determine.so far I understand your class named should be something like this ModulePath_ApplicationPath_ControllerName, so its Default_Application_StaticContentController.
and for better routing I preferred zend manual. you can try this tutorial for route. it would help for you.

Using Soap in magento

I'm trying to follow the information about how to use soap in magento, but always get same message in error.log
If any one experience something similar, that could give me some tip, it will be welcome.
"PHP Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://www.site.com/index.php/api/?wsdl' : failed to load external entity "http://www.site.com/index.php/api/?wsdl"\n in /var/www/test.php on line 1"
$client = new SoapClient('http://www.site.com/api/?wsdl');
$session = $client->login('apiUser', 'apiKey');
$result = $client->call($session, 'somestuff.method');
$result = $client->call($session, 'somestuff.method', 'arg1');
$result = $client->call($session, 'somestuff.method', array('arg1', 'arg2', 'arg3'));
$result = $client->multiCall($session, array(
array('somestuff.method'),
array('somestuff.method', 'arg1'),
array('somestuff.method', array('arg1', 'arg2'))
));
// If you don't need the session anymore
$client->endSession($session);
where you have www.site.com in your SOAP code, replace it with localhost or whatever the correct URL is for your server. You'll also need to replace somestuff.method with real objects and methods as per the Magento documentation

Zend framework ignores custom helper path in application.ini

I have my view helper in Library/My/View/Helper/LoadSkin.php, I added this line in application.ini : resources.view.helperPath.My_View_Helper = "My/View/Helper" but I'm still getting
Fatal error: Uncaught exception 'Zend_Loader_PluginLoader_Exception' with message
'Plugin by name 'LoadSkin' was not found in the registry; used paths: Zend_View_Helper_: Zend/View
/Helper/;C:/Program Files (x86)/Zend/Apache2/htdocs/TinOuzel/application/views\helpers/'
This looks like ZF stills looks for helper in default path ;/
My namespacje is registered in bootstrap:
protected function _initAutoloader ()
{
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('My_');
$autoloader->suppressNotFoundWarnings(true);
return $autoloader;
}
in this case , you must had overridden the default view object
in much clear example , you are using something like :
$view = new Zend_View();
mostly somewhere in your bootstrap file , just remove it and you would be okay