I'm trying to subclassing the FileCollectionService class from third party extension. But it takes not place.
ext_typoscript_setup.txt:
config.tx_extbase{
persistence{
classes{
SKYFILLERS\SfFilecollectionGallery\Service\FileCollectionService {
subclasses {
TxFileCollectionService = FalkRoeder\MyExt\Service\FileCollectionService
}
}
}
}
}
my FileCollectionService.php put in Classes/Service
<?php
namespace FalkRoeder\MyExt\Service;
/**
* FileCollectionService
*/
class FileCollectionService extends \SKYFILLERS\SfFilecollectionGallery\Service\FileCollectionService {
/**
* #return array
*/
public function methodToOverwrite() {
...
}
}
to get it work, I needed to add the following code to ext_typoscript_setup.txt:
config.tx_extbase {
objects {
SKYFILLERS\SfFilecollectionGallery\Service\FileCollectionService.className = FalkRoeder\MyExt\Service\FileCollectionService
}
}
Try to something Like this.
config.tx_extbase{
persistence{
classes{
SKYFILLERS\\SfFilecollectionGallery\\Service\\FileCollectionService {
subclasses {
TxFileCollectionService = VendorName\ExtensionKey\Classes\Utility\FileCollectionService
}
}
}
}
}
Related
Is there a way to add your own directive to the existing ag-grid's IHeaderComponent and modify the header content/behavior?
I created my own IHeaderComponent and used it in the ag-grid, but facing difficulty adding my own directive in the header. All the TS example on their site doesn't help much either, since I'm stuck with angular 1.6. In addition, what is the correct way to pass my dependencies to my IHeaderComponent since I cannot use IHeaderAngularComponent.
Any suggestions?
Edit:
My first stab of it, kind a ugly how I pass my dependencies, not sure if that is the proper way to do it.
class MyHeader {
/**
* #implements {IHeaderComp}
*/
constructor() {
if (!MyHeader.injector) {
MyHeader.injector = angular.element('[ng-app=myApp]').injector();
}
this.injector = MyHeader.injector;
this.dependencies = ['$log'];
}
/**
* #param {IHeaderCompParams} params
*/
init(params) {
this.params = params;
this.eGui = document.createElement('div');
this.eGui.innerHTML = '<span class="ag-header-cell-text" ref="eText" role="columnheader"></span>';
this.eText = this.eGui.querySelector(".ag-header-cell-text");
this.eText.textContent = params.displayName;
this.initAngular();
}
initAngular() {
this.dependencies = _.compact(this.dependencies);
this.dependencies.forEach(dep => this[dep] = this.injector.get(dep));
}
getGui() {
return this.eGui;
}
destroy() {
if (this.params.enableSorting) {
this.eGui.removeEventListener('click', this.sortRequestListener);
this.params.column.removeEventListener('sortChanged', this.onSortChangedListener);
}
}
onSortRequested(event) {
if (this.params.enableSorting) {
//...
}
}
onSortChanged() {
if (this.params.enableSorting) {
//...
}
}
initSorting() {
if (this.params.enableSorting) {
//...
}
}
}
Have you checked an official demo for custom headerComponent?
According to your code, to handle click, hover or any other event you need to define a listener. You are handling dispose with removeEventListener, which is good, but where is a subscription?
So as example, you need to append on init step:
let youHeader = this.eGui.querySelector(".ag-header-cell-text");
youHeader.addEventListener('click', this.youCustomClickHandler);
youCustomClickHandler(){
... your logic here
}
You can specify your enable\disable condition on init step (not exactly inside the function)
In the first place I had to configure parameters using the class "ParametersCompilerPass" to get data from database.Here si my class :
class ParametersCompilerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
$em = $container->get('doctrine.orm.default_entity_manager');
$boutique = $em->getRepository('AcmeBundle:Boutique')->findOneByNom($container->getParameter('boutique.config'));
if(null !== $boutique){
$container->setParameter('url_site', $boutique->getUrl());
$container->setParameter('idboutique', $boutique->getId());
}else{
$container->setParameter('url_site', null);
$container->setParameter('idboutique', 0);
}
}
}
and when i set a parameter from request, it dont work, i tried in adding this code :
$request = $container->get('request_stack')->getCurrentRequest();
if($request->getMethod() == 'POST'){
if (null !== $choixbout = $request->get('choixbout')){
// $this->container->setParameter('idboutique',$choixbout);
}
}
the service request_stack return null.
I do not know how to configure a parameter from a POST variable.
Hope you can help me.
thanks
Is it solid requirement to have the parameter set?
It could be handy to create a service which has a request dependency that can act as a boutique parameter holder.
For example
# app/config/services.yml
app.boutique:
class: AppBundle\Boutique\Boutique
arguments: ['#request_stack']
app.boutique_info_dependant1:
class: AppBundle\Boutique\BoutiqueDependant1
arguments: ['#app.boutique']
app.boutique_info_dependant2:
class: AppBundle\Boutique\BoutiqueDependant2
arguments: ['#app.boutique']
This would be a parameter handler.
# AppBundle/Boutique/Boutique.php
class Boutique
{
/** #var RequestStack */
private $requestStack;
/**
* BoutiqueListener constructor.
* #param ContainerInterface $container
*/
public function __construct(RequestStack $requestStack)
{
$this->requestStack = $requestStack;
}
public function getBoutique()
{
$request = $this->requestStack->getCurrentRequest();
/// here you can add an extra check if the request is master etc.
if ($request->getMethod() == Request::METHOD_POST) {
if (null !== $choixbout = $request->get('choixbout')) {
return $choixbout;
}
}
return null;
}
}
Then using the handler
class BoutiqueDependant1
{
public function __construct(Boutique $boutique)
{
$this->myBoutique = $boutique->getBoutique();
}
}
This does not look like the best solution but could work...
Other option would be to rethink the application architecture to handle boutique information somehow differently.
I have ImageView.class how to get the program to use it instead of the native javax.swing.text.html.ImageView?
javax.swing.text.html.ImageView map = new javax.swing.text.html.ImageView(); //does not work
I was told that it is necessary to use ClassFileTransformer and ClassLoader, but I can not find a working examples
I think that what you really want to do is to...
Extend HTMLEditorKit and override getViewFactory()
Have it return a class that extends HTMLEditorKit.HTMLFactory
In that class, override create() to return your custom view for <img> and super.create() otherwise
Like this:
class MyImageKit extends HTMLEditorKit {
private static final MyImageFactory myFactory = new MyImageFactory();
public ViewFactory getViewFactory() {
return myFactory;
}
static class MyImageFactory extends HTMLFactory {
public View create(Element elem) {
Object type = elem.getAttributes()
.getAttribute(StyleConstants.NameAttribute);
if(type == HTML.Tag.IMG) {
return new MyImageView(elem);
} else {
return super.create(elem);
}
}
}
}
class MyImageView extends ImageView {
MyImageView(Element elem) {
super(elem);
}
protected void setPropertiesFromAttributes() {
super.setPropertiesFromAttributes();
try {
ImageView.class.getDeclaredField("vAlign").set(this, new Float(0.75f));
} catch(Exception e) {
e.printStackTrace();
}
}
}
I mostly use zend_db_table with a paginator, the problem is that it will return zend_db_rows instead the domain objects from my datamapper.
Let's say :
class Content_Model_ArticleMapper {
/*
* #param Zend_Db_Select $select
* #return Zend_Paginator
*/
public function getPaginator($select = null){}
}
I can hack it by overriding _loadAndReturnRow method in a custom rowset
However this is pretty ugly as I don't have a Zend_Db_Row anymore when I query the table.
And loose the methods too like save which I don't want to replicate on the domain object.
:
class Content_Model_DbTable_Rowset_Articles extends Zend_Db_Table_Rowset {
protected function _loadAndReturnRow($position)
{
if (!isset($this->_data[$position])) {
require_once 'Zend/Db/Table/Rowset/Exception.php';
throw new Zend_Db_Table_Rowset_Exception("Data for provided position does not exist");
}
// do we already have a row object for this position?
if (empty($this->_rows[$position])) {
$this->_rows[$position] = new Content_Model_Article($this->_data[$position]);
}
// return the row object
return $this->_rows[$position];
}
}
So my question how do you do this nicely ? :) Do you write custom Paginator adapters?
You can set a rowClass in your DbTable like
DbTable
class Content_Model_DbTable_Article extends Zend_Db_Table_Abstract {
protected $_name = 'article';
public function init() {
$this->setRowClass('Content_Model_Article');
}
}
Domain Model
class Content_Model_Article extends Zend_Db_Table_Row {
//for example
public function getAuthorFullName() {
return $this->author_firstname . ' ' . $this->author_lastname;
}
}
Now rows in your rowset are instances of Content_Model_Article and you can use the Zend_Paginator_Adapter_Iterator.
Using Paginator
$articleTable = new Content_Model_DbTable_Article();
$articleRowset = $articleTable->fetchAll();
$paginator = new Zend_Paginator(Zend_Paginator_Adapter_Iterator($articleRowset));
//now you can loop through the paginator
foreach($paginator as $article) {
echo $article->getAuthorFullName();
}
Is this even possible? For example, say I have an array of Dogs. How do I get code completion to work? Here's code to illustrate the problem. Any advice would be great!
class Dog {
private $name;
public static function init_many(array $names) {
foreach ($names as $n) {
$collection[] = new self($n);
}
return $collection;
}
public function __construct($n) {
$this->name = $n;
}
public function bark() {
return sprintf('woof! my name is %s',
$this->name
);
}
}
$Scoobi = new Dog('scoobi');
$Scoobi-> // code hinting / completion works!
$dogs = Dog::init_many(array('scoobi', 'lassie', 'bingo'));
$dogs[0]-> // code hinting / completion doesn't work!
An indirect way to do this could be
$dogs = Dog::init_many(array('scoobi', 'lassie', 'bingo'));
foreach ($dogs as & $dog)
{
/* #var $dog Dog */
$dog-> //code hinting works here,
//I use this all the time itereting over doctrine collections
}
In Zend Studio 11 I use :
/**
*
* #return Dog[]
*/
public static function init_many(array $names) {
foreach ($names as $n) {
$collection[] = new self($n);
}
return $collection;
}